Skip Navigation

[Resolved] Using breadcrumbs displaying post type w/ category

This support ticket is created 4 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 4 replies, has 2 voices.

Last updated by Waqar 4 years, 2 months ago.

Assisted by: Waqar.

Author
Posts
#1938153

Tell us what you are trying to do?
I am trying to use breadcrumbs. I use RankMath SEO for this (I have also tried Avada Breadcrumbs).

Currently it shows like: Homepage > Apple iPhone 11 Pro Max. I want it to show Homepage > Reparaties > Apple > Apple iPhone 11 Pro Max.

"Reparaties" is a page with all the brands on it and Apple is the category with the models/subpages in it.

I have turnt the has_archive so I can use custom page to display the content (with a view template/loop inside). I have tried to turn it back on, then the breadcrumbs work fine, but my own page designs are then overwritten by toolset archive.

Maybe there is some way to use custom breadcrumbs?

What is the link to your site?
hidden link
hidden link
hidden link

#1939003

Hi,

Thank you for contacting us and I'd be happy to assist.

I found this code snippet in the RankMath SEO's support forum, which can help you with this customization requirement:
hidden link

I hope this helps.

regards,
Waqar

#1940151

Hi Waqar,

Thank you for your reply.

I have almost no programming skills and don't know what those codes do or mean. Will that code not just change the standard breadcrumb for all posts? I have different post types (phone brands; Apple, HTC, etc) and in each post type there are all the phone models (iPhone x, iPhone 11, etc)

#1940153

Is it not possible that when I activate has_archive function, we still let the WordPress Page override the permalink if there is a WordPress Page with the same permalink? So that priority goes to loading the wordpress page instead of the archive page generated by toolset? That would solve my issue

#1941853

Thanks for writing back.

> I have almost no programming skills and don't know what those codes do or mean.
> Will that code not just change the standard breadcrumb for all posts?
> I have different post types (phone brands; Apple, HTC, etc) and in each post type
> there are all the phone models (iPhone x, iPhone 11, etc)

- The code from the other support thread is using the "is_singular('post')" check which will limit it to work only for the single "Post" pages.

You can change the post type slug "post" to make it work for other post types too:
https://developer.wordpress.org/reference/functions/is_singular/

Here is a useful guide on WordPress conditional tags:
https://codex.wordpress.org/Conditional_Tags

If you're not comfortable with making these custom code changes on your own, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

> Is it not possible that when I activate has_archive function, we still let the WordPress Page
> override the permalink if there is a WordPress Page with the same permalink?
> So that priority goes to loading the wordpress page instead of the archive page
> generated by toolset? That would solve my issue

- The way WordPress works, it will show the archive page if the same slug is shared by an archive and a regular page.

A workaround can be to rename the slug of the page slightly ( e.g. {yourwebsite.com}/reparaties-page/ ) and redirect the archive page ( i.e. {yourwebsite.com}/reparaties/ ) to that page:
hidden link

Example:


function redirect_cpt_archive() {
    if( is_post_type_archive( 'reparaties' ) ) {
        wp_redirect( home_url( 'reparaties-page' ), 301 );
        exit();
    }
}
add_action( 'template_redirect', 'redirect_cpt_archive' );

As a result, when someone will try to visit the archive page {yourwebsite.com}/reparaties/ it will redirect to the page {yourwebsite.com}/reparaties-page/