• Resolved gecko_guy

    (@gecko_guy)


    Hi,

    I’ve been reading the API docs and can’t seem to get this working.

    I have a custom post type, with its own term taxonomy for “category” and “tag”.

    CPT = projects
    CPT Cat = project_category
    CPT Tag = project_tag

    I would like to noindex and nofollow all the project tags, but I can only do this if I edit each new tag one at a time.

    Is there a filter that works to do this?

    overwrite term meta, untested:

    This results in white screen.

    I also found this old reply, but it doesn’t seem to have any effect:

    add_filter( 'the_seo_framework_robots_meta_array', 'my_robots_adjustments', 10, 1 );
    function my_robots_adjustments( $robots = array() ) {
    
    	// Pick one or leave both conditions:
    	if ( 'mycoolposts' === get_post_type() || is_post_type_archive( 'mycoolposts' ) ) {
    		// Keys match the value. Legacy code.
    		$robots['noindex'] = 'noindex';
    		$robots['nofollow'] = 'nofollow';
    	}
    
    	return $robots;
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hi @gecko_guy,

    If I understand your question correctly, you’d like to add noindex and nofollow to all project_tags automatically.

    Then this code should work:

    add_filter( 'the_seo_framework_robots_meta_array', 'my_robots_adjustments', 10, 1 );
    function my_robots_adjustments( $meta = array() ) {
    
    	if ( is_tag( 'project_tag' ) ) {
    		$meta['noindex'] = 'noindex';
    		$meta['nofollow'] = 'nofollow';
    	}
    
    	return $meta;
    }

    It’s not the perfect solution because the admin-side isn’t (currently) aware of this code. But it does its job perfectly otherwise.

    Sidenote: I need to clean up the filters page so I just added a warning on it. The one you tried using isn’t available anymore and it even misses a code constructor, ergo the white screen.

    Thread Starter gecko_guy

    (@gecko_guy)

    HI @cybr,

    Thanks. It doesn’t really matter if the admin end awareness isn’t there (although that would be nice), so that’s perfectly fine for now.

    Many thanks for your help

    @gecko_guy please consider leaving a review for TSF plugin ?? You don’t have to of course, I’m not your boss ?? Have a good rest of the weekend!

    Thread Starter gecko_guy

    (@gecko_guy)

    lol! I will definitely post a review after I’ve had a chance to fully test the plugin. I’ve been a Yoast junkie for many years, but decided to try TSF because it has some very attractive features, not least of which is the lower “bloat factor” ??

    So far I’m happy, but it’s a complex area as we all know, so before I review TSF, I will first need to see how things go.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Possible to No-index custom post type taxonomy’ is closed to new replies.