• Resolved jimmi_steen

    (@jimmi_steen)


    I want to progratimcally change in functions.php custom taxonomy terms SEO title and descrtiption. How can i do it? I have the id of the term but I’m not able to update the SEO Framework fields

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

    (@cybr)

    Hi @jimmi_steen,

    There are two filters available for adjusting term input data after they’ve been saved:

    the_seo_framework_current_term_meta // adjusting CURRENT data
    the_seo_framework_get_term_meta // adjusting FALLBACK data
    

    The fallback data is only accessible on new terms, or terms that haven’t been edited since TSF was active.

    Each filter has two parameters, and they both work like so:

    add_filter( 'the_seo_framework_current_term_meta', function( $data, $term_id ) {
    
    	if ( 2 === $term_id ) { 
    		// Adjust $data for $term_id 2 here.
    		$data['doctitle'] = 'Title...';
    		$data['description'] = 'Description...';
    		$data['noindex'] = 0;
    		$data['nofollow'] = 1; // nofollow is now enabled.
    		$data['noarchive'] = 0;
    	}
    	return $data;
    }, 10, 2 );
    

    If you wish to adjust the term meta on a “term-update action”, then you should check out WordPress function update_term_meta(), which uses update_metadata( 'term', ...[] ). There, you can inspect and rewrite the data via various hooks. It’s not very convenient, as they require you to loop a filter.

    So, I should implement a filter which allows you to adjust the data easily on the save action.
    I’ve created issue 316 for this, which should be brought with version 3.1 of TSF.

    I expect 3.1 to be released in July 2018.

    Cheers ??

Viewing 1 replies (of 1 total)
  • The topic ‘How to progratimcally change tax term SEO’ is closed to new replies.