Missing breadcrumb item on docs site when searching


It should probably read more like:

Search Results: classicpress

or

Home / Search / classicpress


Image Source: https://docs.classicpress.net/?s=classicpress

3 Likes

The site is using an old script by Justin Tadlock: Breadcrumb Trail.

The problem is with this code:

    public function do_search_items() {

		if ( is_paged() )
			$this->items[] = '<a href="' . get_search_link() . '" title="' . esc_attr( sprintf( $this->args['labels']['search'], get_search_query() ) ) . '">' . sprintf( $this->args['labels']['search'], get_search_query() ) . '</a>';

		elseif ( true === $this->args['show_title'] )
			$this->items[] = sprintf( $this->args['labels']['search'], get_search_query() );
	}

Tadlock himself has since reimagined that script at https://github.com/themehybrid/hybrid-breadcrumbs “as a better drop-in package for theme authors to use.” I suggest we take him at his word and give the updated script a try.

3 Likes

Justin’s breadcrumbs plugin has always been the very best code available – if he’s updated the implementation, it’s definitely worth a good look.

1 Like

The error does not seem to be in that code, to me (simply because :hammer: debugging it by returning anything else in those statements or even returning a default wont change the issue)

I have found that the theme expects a reference page slug acting as “search and landing page” for the code reference. We however use code-reference.
(see search.php line 18)

Thus fixing that, we would get this breadcrumb:
Search Results: Home / Code Reference / wp_

I think that is OK for now since that search only acts/is available on the actual code ref.
I noticed that if you search from a single code ref, then the breadcrumb still will show the same thus not being a “true” breadcrumb in the sense of a “where I came from” navigation, but still helpful

Let me know what you think.

3 Likes

Good job!

I still think it’s worth looking at updating when someone has tome to look at the new code. But I also agree that this is perfectly fine for now.

3 Likes