0
votes

On each page of my website I have breadcrumb links above the page content. What I want to do is change the link so that when it is 'Home>Events>Example', the 'Events' link will redirect users to an events page instead of a category page.

So in summary, at the minute, clicking the Events breadcrumb link brings you to a category page of Event posts. I want it to instead bring users to a specific Event listings page.

What's the best way of doing this? My initial thought was to edit 'category-3.php' to replicate the Events page, but is there a better way? I want to do this for every scenario across the site where 'Events' is in the breadcrumb links.

Thanks in advance.

1

1 Answers

0
votes

Without seeing the code for the breadcrumb I'm going to have to make some assumptions. I imagine it iterates through a script somewhere that builds the breadcrumb based on the page structure. If you find that loop you can do an str_replace on it, also assuming that events pertains to a specific category with a URL that always remains the same.

So if you find the loop and find the variable that holds the link for event you can follow this example:

//crumb would be the variable that helps to build the entire bread crumb in the loop through .=
//e.g. $mainBreadCrumb.=$crumb each time the loop makes a pass

$crumb = '<a href="index.php/category-3.php/">Events</a>';

$crumb = str_replace("<a href="index.php/category-3.php/">Events</a>", "<a href="eventspage.php">Events</a>", $crumb);

That should get the job done, again, assuming that the original Events breadcrumb link does not change. If you need further help post the breadcrumb code.