Skip Navigation

[Resolved] Customise the breadcrumbs so that a Toolset Content Template returns to a page

This support ticket is created 4 years, 5 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)

Tagged: 

This topic contains 4 replies, has 3 voices.

Last updated by Robert Davies 4 years, 5 months ago.

Assisted by: Waqar.

Author
Posts
#1840323

Tell us what you are trying to do?
We are upgrading our toolset based site (hidden link). The test version of this site is at:
hidden link. This will be migrated to hidden link when complete and the test site removed.

We have a search (Acquisitions tab on-site). This has a breadcrumb position of
Home>Aquisition Search
The search results take us to a custom post type the content of which is controlled by a content type template.
At this point, the breadcrumbs correctly change to

home>acquisitions>[name of post]
where acquisitions is the category for our custom type

I need to change that so that when in one of the posts the breadcrumbs are showing
Home>Aquisition Search>[name of post}

Do you know of any way to do this?

What is the link to your site?
We are working a test site the link is
hidden link

#1841037

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

What are you using to generate the breadcrumbs?

#1841041

Hi Nigel

We're using the Astra theme pro breadcrumbs
But have no issue in switching to another solution if it solves the problem

#1841755

Hi,

Thanks for writing back.

During testing and research, I found that the Astra theme offers a "astra_breadcrumb_trail" hook, which can be used to customize the output of the breadcrumbs.

For example, to replace the post type link with the search page link in the breadcrumb of single post pages, you can use:


function customize_breadcrumb_callback( $breadcrumb ) {
	// Maybe modify $breadcrumb
	if(is_singular()) {

		$search_page_id = 12345;
		$search_page_title = get_the_title($search_page_id);
		$search_page_url = get_the_permalink($search_page_id);

		$breadcrumb = '<nav role="navigation" aria-label="Breadcrumbs" class="breadcrumb-trail breadcrumbs">
						<div class="ast-breadcrumbs">
							<ul class="trail-items" itemscope="" itemtype="<em><u>hidden link</u></em>">
								<meta content="3" name="numberOfItems">
								<meta name="itemListOrder" content="Ascending">
								<li itemprop="itemListElement" itemscope="" itemtype="<em><u>hidden link</u></em>" class="trail-item trail-begin">
									<a href="'.get_home_url().'" rel="home" itemprop="item">
									<span itemprop="name">Home</span>
									</a>
									<meta itemprop="position" content="1">
								</li>
								<li itemprop="itemListElement" itemscope="" itemtype="<em><u>hidden link</u></em>" class="trail-item">
									<a href="'.$search_page_url.'" itemprop="item">
									<span itemprop="name">'.$search_page_title.'</span>
									</a>
									<meta itemprop="position" content="2">
								</li>
								<li class="trail-item trail-end">
									<span><span>'.get_the_title().'</span></span>
								</li>
							</ul>
						</div>
						</nav>';
	}
	
	return $breadcrumb;
}
add_filter( 'astra_breadcrumb_trail', 'customize_breadcrumb_callback', 10, 1 );

Note: You'll replace "12345" with the actual ID of your search page.

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through active theme's "functions.php" file.

The custom code examples from our forum are shared to get you started in the right direction. You're welcome to adjust them as needed and for more personalized customization assistance, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

regards,
Waqar

#1843195

My issue is resolved now. Thank you!