• Resolved purecreativeuk

    (@purecreativeuk)


    I’ve been required to be able to add the parent taxonomy to titles, for example in an ecommerce site where you need to show the level above in the hierarchy.

    I’ve come up with a quick solution to do this but it means hacking the code for All In One.

    Is there anything on the roadmap for this to be officially implemented? I’ve seen requests for it.

    My code involves changes to the apply_tax_title_format function in order to retrieve the parent taxonomy details and add the %category_parent% variable.

    https://www.ads-software.com/plugins/all-in-one-seo-pack/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi purecreativeuk,

    If you need to do something like this, I’d suggest using the aioseop_title filter to modify the title instead; hacking the plugin is not advisable, and of course won’t persist past the next plugin update. Let me know if you need some help with this, and if so, post your code for getting the parent title as well.

    Thread Starter purecreativeuk

    (@purecreativeuk)

    I didn’t realise that filter existed.

    That’s sorted it right out.

    I now have a filter in place for my Woocommerce site:

    add_filter('aioseop_title', 'tax_custom_title');
    
    function tax_custom_title($title) {
    if ( is_taxonomy('product_brand') ) {
            $term = get_term_by('slug', get_query_var( 'term' ), 'product_brand' );
            $termparent = get_term_by('id',$term->parent, 'product_brand');
            $title = $termparent->name .' '. $title;
       }
       return $title;
    }

    Hi purecreativeuk,

    That looks good to me! You might also want to check for the existence of the term / term parent just in case there isn’t one.

    Thread Starter purecreativeuk

    (@purecreativeuk)

    Yes will add that in. Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Parent category option’ is closed to new replies.