Support » Plugin: The SEO Framework » Remove from a taxonomy?

  • Hi there,

    How can I choose to remove the SEO options from a particular taxonomy? (It’s a custom taxonomy I created).

    Thanks
    Shaun

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

    (@cybr)

    Hi Shaun,

    Could you elaborate on which options you’d like to have disabled for the particular taxonomy?

    Cheers!

    Hi,

    I’d like the remove the entire “SEO” box, because it’s not necessary on this taxonomy (it’s hidden on the frontend).

    Regards
    Shaun

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi Shaun,

    My apologies for this late reply, I (among many other plugin authors) still need to get used to the new support forum system.

    If the taxonomy is detected as a public taxonomy, the SEO Settings will automatically be added.

    You can remove the SEO Box output be removing the action, but this is not recommended and can lead to more maintenance.

    If it really bothers you, I’d like to write you a code snippet that would allow this behavior to stop.

    However, I recommend to remove the public visibility from the taxonomy if the taxonomy will not ever be shown on the front-end. Please refer to the register_taxonomy() function arguments (i.e. public).

    I hope this clears things up! Have a great day! 🙂

    Hi,

    I’m using CustomPress which sets “public” to “advanced”, letting you pick and choose the settings but it doesn’t make the required change you’re talking about.

    https://premium.wpmudev.org/project/custompress/

    So if you can write a custom snippet that would be perfect, thanks!

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi Shaun,

    The categories created by CustomPress seem to be bound to the default post meta.
    In order to remove the Taxonomial SEO Settings overview, you’d need to use this code snippet:

    add_action( 'current_screen', 'my_remove_tsf_metabox', 9 );
    function my_remove_tsf_metabox() {
    	if ( function_exists( 'the_seo_framework' ) ) {
    		remove_action( 'current_screen', array( the_seo_framework(), 'add_taxonomy_seo_box_init' ), 10 );
    	}
    }
    

    I hope this helps! Cheers 🙂

    Hi,

    That removes it from all taxonomies, including the default.. is there a way to pick and choose which taxonomies to remove it from?

    Regards
    Shaun

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi Shaun,

    You’d have to look for the global $current_screen variable, and determine the taxonomy slug from that.

    Unfortunately, I can’t guess the slug from here; so here’s the code that will allow you to find the slug; adjust it according to the comments in the code:

    
    add_action( 'current_screen', 'my_remove_tsf_metabox', 9 );
    function my_remove_tsf_metabox() {
    	if ( function_exists( 'the_seo_framework' ) ) {
    		global $current_screen;
    
    		//* Dump the name you need to fill in 'taxonomy_slug' further down below. Remove the following line after you've found its name.
    		var_dump( $current_screen['taxonomy'] );
    
    		//* Replace 'taxonomy_slug' with the one found from the dump.
    		if ( isset( $current_screen['taxonomy'] ) && 'taxonomy_slug' === $current_screen['taxonomy'] )
    			remove_action( 'current_screen', array( the_seo_framework(), 'add_taxonomy_seo_box_init' ), 10 );
    	}
    }

    If you have any doubts, feel free to ask away! Cheers 🙂

    Thanks, I had to adjust the code to use $current_screen as an object instead of an array but after that it worked perfectly.

    Updated code, for reference:

    add_action( 'current_screen', 'my_remove_tsf_metabox', 9 );
    function my_remove_tsf_metabox() {
    	if ( function_exists( 'the_seo_framework' ) ) {
    		global $current_screen;
    
    		//* Dump the name you need to fill in 'taxonomy_slug' further down below. Remove the following line after you've found its name.
    		var_dump( $current_screen->taxonomy );
    
    		//* Replace 'taxonomy_slug' with the one found from the dump.
    		if ( isset( $current_screen->taxonomy ) && 'taxonomy_slug' === $current_screen->taxonomy )
    			remove_action( 'current_screen', array( the_seo_framework(), 'add_taxonomy_seo_box_init' ), 10 );
    	}
    }
    Plugin Author Sybre Waaijer

    (@cybr)

    Thank you for the correction 🙂

    If you have any more questions, feel free to ask! Cheers :).

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Remove from a taxonomy?’ is closed to new replies.