Support » Plugin: The SEO Framework » Custom Taxonomy In SEO Fields

  • Joe G.

    (@webgmclassics)


    Is is possible to place a custom taxonomy in the page title and description tags? I need to do this programmatically.

    Use case:
    I have a woocommerce store selling car parts; there is a custom taxonomy for the make / model / year data. I need to append this information to the page title and the page descriptions. Ideally, I would like to do this from the theme template. But, if that’s not possible I can hook in through functions.php or a custom plugin.

Viewing 1 replies (of 1 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hi Joe,

    My apologies for the late response. I’m very busy with releasing v3.1.

    We’re working on this: https://github.com/sybrew/the-seo-framework/issues/140
    Until then, titles are handled very statically. v3.1 does open a door for implementing this, so that’s good new 🙂

    If you wish to do it programmatically before that’s released, I recommend waiting out for TSF v3.1. The update is ready, and the release notes thereof will be released duly.

    The gist is that you’ll want to add values onto these filters:

    the_seo_framework_title_from_generation
    the_seo_framework_fetched_description_excerpt
    

    get_post_type( $id ) will be your friend in this.

    For example, for the title:

    // TSF v3.1+
    add_filter( 'the_seo_framework_title_from_generation', function( $title, $args ) {
    
    	if ( the_seo_framework()->is_singular() ) { // Also checks in admin.
    		if ( isset( $args['id'] ) ) { // External call, or in a loop...
    			$id = $args['id'];
    		} else { // Front-end or admin "current post" generation call.
    			$id = the_seo_framework()->get_the_real_ID();
    		}
    
    		$post_type = get_post_type( $id );
    
    		if ( 'product' === $post_type ) {
    			// Adjust $title here.
    		}
    	}
    
    	return $title;
    }, 20, 2 );

    I recommend hiring a developer for these custom adjustments until we supply a user interface. It’ll require some fiddling and testing to get exactly what you want.

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Taxonomy In SEO Fields’ is closed to new replies.