WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
Exclude category from breadcrumbs? (7 posts)

  1. jenseo
    Member
    Posted 5 months ago #

    Hi!
    I recently migrated from All in one SEO to WordPress SEO and first of all I just want to ask you for an amazing plugin, it does pretty much everything and I just love that!

    Now to my question:

    I have a featured category on my blog, where I'm adding posts to be displayed on certain areas of the blog, but this category name is never displayed in the blog. I have filtered it out.

    My problem is that this category is still showing up in the breadcrumbs. Is there a way to filter it out there as well, making it invisible to my visitors?

    To be clear: Most post of my blog only excists in one category, but featured posts always is added to two categories. But, the featured name shouldn't be seen on the front end of the site...

    Thanks again for a wonderful plugin!

    // Jens.

    https://wordpress.org/plugins/wordpress-seo/

  2. jrf
    Member
    Posted 5 months ago #

    There are filters available for that. Have a look at this thread: http://wordpress.org/support/topic/how-do-i-remove-cpt-from-breadcrumb-trail

  3. jenseo
    Member
    Posted 5 months ago #

    Thanks jrf, looks to be what I need!

    I'm not really sure how to solve the following scenario though:

    If I base my filter on the example in the thread you linked, I'm guessing that it will remove the category I specify, but I would also like it to choose the other category from the post.

    Any suggestion how I can apply this in a filter?

    Thanks!

    // Jens.

  4. jrf
    Member
    Posted 5 months ago #

    In your case I'd use the other filter and code along the lines of:

    add_filter( 'wpseo_breadcrumb_links', 'my_breadcrumb_filter_function' );
    
    function my_breadcrumb_filter_function( $crumbs ) {
    	/* Do something, for instance:
    	   - test the crumb for the featured category & replace it with another, i.e.:
    	foreach( $crumbs as $i => $crumb ) {
    		// Test for the unwanted crumb - replace ## with your term id
    		if( isset( $crumb['term'] ) && $crumb['term'] == ## && isset( $GLOBALS['post'] ) {
    			// Add some arguments to get your term
    			$terms = wp_get_object_terms( $GLOBALS['post']->ID, 'category', $args );
    			if( ! is_wp_error( $terms ) ) {
    				// -> Do something to get your preferred term from the $terms array
    				$myterm = ....;
    				$crumbs[$i] = array(
    					'term' => $mytermid,
    				);
    			}
    		}
    	}
    	*/
    	return $crumbs;
    }
  5. jenseo
    Member
    Posted 5 months ago #

    Awesome, I'll give it a spin! Thanks a lot!

  6. jrf
    Member
    Posted 5 months ago #

    Good luck. Could you mark this topic as resolved ?

  7. scifenefics
    Member
    Posted 4 months ago #

    I had this same problem and solved it by hiding it with this CSS

    #breadcrumbs span:nth-child(2) a {
    display:none;
    }

    I wanted my sites breadcrumbs to flow like:
    Home > Businesses > Restaurants > Greasy Joes

    But my theme (Geocraft) pulled up a surprise and gave me:
    Home > Business Listings > Businesses > Restaurants > Greasy Joes

    Since "Business Listings" is 2nd in the list, this CSS looks within the "#breadcrumbs" tag then in the "spans" then the second child in the list "(2)" and finally the link "a" and I made it hidden.

    Worked well for me. Yoast WordPress SEO 1.5.2.7

Reply

You must log in to post.

About this Plugin

About this Topic