ACF CPT Breadcrumb

#640567
  • Resolved ANF
    Rank Math free

    Hello RankMath,
    I have created a CPT with ACF called “car brands”. The parent page is website.com/car-brands/ with custom posts being website.com/car-brands/toyota/ for example. Can you please advise on how to display the parent page (Car Brands) in the breadcrumb when viewing a child page (/car-brands/toyota/), as only the Homepage (Home) and Child Page (Toyota) are displayed as breadcrumbs, not the parent (Car Brands) page.

    The current Breadcrumb is: Home > Toyota

    The desired Breadcrumb is: Home > Car Brands > Toyota

    Thank you

Viewing 15 replies - 1 through 15 (of 22 total)
  • Hello,

    Thank you for your query and we are so sorry about the trouble this must have caused.

    This may require some coding on your part to apply the desired breadcrumbs format.

    Please try this code below:

    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
    	global $post;
    	$post_type = get_post_type();
    	if ($post_type == 'car-brands') {
    		$parent = get_post_parent();
    		if($post->post_parent) {
    			$crumbs[1][0] = get_the_title($parent);
    			$crumbs[1][1] = get_the_permalink($parent); 
    			$crumbs[2][0] = get_the_title();
    			return $crumbs;	
    		}
    	}
    	return $crumbs;
    }, 10, 2);

    If that doesn’t work, we can manually apply the parent page in the breadcrumbs. Use this code instead:

    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
    	$post_type = get_post_type(get_queried_object());
    	
    	if ($post_type == 'car-brands') {
    		$crumbs[1][0] = 'Car Brands';
    		$crumbs[1][1] = 'https://EXAMPLE.COM/car-brands/'; // URL of CPT slug
    		$crumbs[2][0] = get_the_title();
    	}
    
    	return $crumbs;
    }, 10, 2);

    You may refer to this guide on how to add filters to your website: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps and please do not hesitate to let us know if you need my assistance with anything else.

    ANF
    Rank Math free

    Hello Jeremy,
    Thank you for your assistance.

    The second code snippet (manually apply the parent page) appears to work, however, if the website goes a level deeper, then only the parent page breadcrumb is displayed and not the next level down.

    For example, with the manual PHP code the Breadcrumb is now: Home > Car Brands

    However, if the page is a couple of levels deep, the desired Breadcrumb is: Home > Car Brands > Toyota > Facts

    Sophia

    Hello,

    Thank you for your patience.

    Could you please confirm if you have already set the Primary Taxonomy in Rank Math > Titles & Meta > [Car Brands] Post type?
    https://rankmath.com/kb/how-to-choose-a-primary-category/

    Also, please select the lowest child category as the Primary Category for those single post types.

    Let us know how this goes.

    ANF
    Rank Math free

    Hello Reinelle,
    I don’t have an option to select a Primary Category for a custom post type. This option only exists for Posts. Is this definitely an option that should appear for custom post types?

    Thank you

    Hello,

    Thank you for getting back to us.

    To help you investigate this issue, we might need to take a closer look at your website and settings. Please follow these steps:

    • Edit the first post on this ticket and include your WordPress and FTP logins in the Sensitive Data section. This is a secure section that only our support staff can access.
      Sensitive Data Section
    • Make sure you take a complete backup of your website before sharing the information with us.
    • If you prefer, you can use this plugin to generate a temporary login URL to your website and share that with us instead: https://wordpress.org/plugins/temporary-login-without-password/
    • You can also use this plugin to monitor what changes our staff might make on your website (if any): https://wordpress.org/plugins/wp-security-audit-log/

    We appreciate your cooperation and patience. Thank you for choosing Rank Math.

    ANF
    Rank Math free

    Hello Rank Math,
    As the development site is not public facing, access isn’t possible. Is there another way this can be resolved?

    Hello,

    Thank you for your patience, and we understand the situation.

    Could you please confirm if this option is not showing in Rank Math > Titles & Meta > Car Brands?

    tax

    You can share images as well by uploading using this tool and adding the link here.

    Looking forward to helping you.

    ANF
    Rank Math free

    Hello Reinelle,
    This option is not showing in Rank Math > Titles & Meta > Car Brands. There is no option to specify a Primary Taxonomy for the Car Brands CPT.

    Hello,

    To help you investigate this issue, we might need to take a closer look at your website and settings. Please follow these steps:

    • Edit the first post on this ticket and include your WordPress and FTP logins in the Sensitive Data section. This is a secure section that only our support staff can access.
      Sensitive Data Section
    • Make sure you take a complete backup of your website before sharing the information with us.
    • If you prefer, you can use this plugin to generate a temporary login URL to your website and share that with us instead: https://wordpress.org/plugins/temporary-login-without-password/
    • You can also use this plugin to monitor what changes our staff might make on your website (if any): https://wordpress.org/plugins/wp-security-audit-log/

    We appreciate your cooperation and patience. Thank you for choosing Rank Math.

    ANF
    Rank Math free

    Hello Great,
    Please ready my reply above regarding website access.

    ANF
    Rank Math free

    Please ready my reply above regarding website access.

    Hello,

    Thank you for pointing that out, apologize for the confusion.

    In this case, it could be a bit tricky to help here, as this looks like an unconventional case.

    Would you be able to record a video of your backend options? Specifically the options at Rank Math > Titles & Meta > Car Brands. You can use loom.com to record the video. Also, it would be really helpful if you could just duplicate the website into a staging and give us access to the staging so we can further investigate this.

    You could use WP Staging to create a staging version of your website in one click. Or you could use the Duplicator plugin to create a live duplicate we could check out.

    Thank you for your patience and cooperation. Looking forward to hearing back from you.

    ANF
    Rank Math free

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hello,

    Thank you for your patience.

    Could you please confirm how are your CPT’s created? Is it a feature from your theme? Or installed via a separate plugin like CPT UI?

    If it’s from the CPT UI plugin, please share the screenshot of the Edit Post Type page so we can check the settings as the Primary Taxonomy option is showing fine on our test install.

    Here’s a link for that as well (add your wp-admin in the URL):
    /wp-admin/admin.php?page=cptui_manage_post_types&action=edit

    Looking forward to helping you.

    ANF
    Rank Math free

    Hello Reinelle,
    I have added information to the “Sensitive Data” reply.

Viewing 15 replies - 1 through 15 (of 22 total)

The ticket ‘ACF CPT Breadcrumb’ is closed to new replies.