Datafeedr Support Forums  

Go Back   Datafeedr Support Forums > Current Version (V3) Forum > Questions
Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Important - The support forums are now in "read-only" mode as we transition to an alternative help desk solution. Feel free to contact us here with any of your questions or search the forums for an existing solution.
 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 12th, 2012, 04:00 PM
dhilditch dhilditch is offline
 
Join Date: Feb 2012
Location: In my house
Posts: 108
Default Category Parent Name Shortcode

Hi - we're trying to figure out how to access the category parent name for SEO reasons so we can stick it in our <h2> tags</h2>.

You can see what we have so far here:

http://www.fitness-saver.com/fitness.../?brand=adidas

We see [category.name] and also [category.parentID] but can't figure out how to get the name of the parent category.

Can you help please?
  #2  
Old April 12th, 2012, 06:03 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Hi

Normally, you could do something like this in your Views:

PHP Code:
<?php echo datafeedr()->category_name($category->parent); ?>
But for some reason, that's not working...

So, in the meantime, you could add the following function to your theme's functions.php file:

PHP Code:
function dfr_get_parent_name($id) {
    global 
$wpdb;
    
$parent_name $wpdb->get_var$wpdb->prepare("
        SELECT name 
        FROM "
.$wpdb->prefix."dfr_shop_cats
        WHERE id = %d"

        
$id
    
) );
    return 
$parent_name;

Then you can do something like this in your views:

PHP Code:
<?php echo dfr_get_parent_name($category->parent); ?>
Eric
  #3  
Old May 16th, 2012, 11:53 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Quote:
Originally Posted by Eric View Post
Normally, you could do something like this in your Views:

PHP Code:
<?php echo datafeedr()->category_name($category->parent); ?>
But for some reason, that's not working...
This has been fixed in v3.7.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Formating Sub Category Links in its Parent? laurenceuk Questions 3 November 1st, 2011 12:04 PM
How do I change a sub category to a parent category? sean83 Problems 1 August 18th, 2011 08:13 PM
2 Parent Category Request tkh378 Feature Requests 1 March 2nd, 2011 04:50 PM


All times are GMT -5. The time now is 08:10 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.