Search page breadcrumb trail filling function
-
I recently installed a plugin “Nice Search” that redirects search URLs from ?s=FOO to /search/foo and converts spaces to + symbols.
The following function obviously conflicts (visually) with my nice permalink structure for search urls.
/** * A Breadcrumb Trail Filling Function * * This functions fills a breadcrumb for a search page. */ protected function do_search() { //Place the breadcrumb in the trail, uses the constructor to set the title, prefix, and suffix, get a pointer to it in return $breadcrumb = $this->add(new bcn_breadcrumb(get_search_query(), $this->opt['Hsearch_template_no_anchor'], array('search', 'current-item'))); //If we're paged, or allowing the current item to be linked, let's link to the first page if($this->opt['bcurrent_item_linked'] || (is_paged() && $this->opt['bpaged_display'])) { //Since we are paged and are linking the root breadcrumb, time to change to the regular template $breadcrumb->set_template($this->opt['Hsearch_template']); //Figure out the hyperlink for the anchor $url = home_url('?s=' . str_replace(' ', '+', get_search_query())); //Figure out the anchor for the search $breadcrumb->set_url($url); } }
This should fix the issue
/** * A Breadcrumb Trail Filling Function * * This functions fills a breadcrumb for a search page. */ protected function do_search() { //Place the breadcrumb in the trail, uses the constructor to set the title, prefix, and suffix, get a pointer to it in return $breadcrumb = $this->add(new bcn_breadcrumb(get_search_query(), $this->opt['Hsearch_template_no_anchor'], array('search', 'current-item'))); //If we're paged, or allowing the current item to be linked, let's link to the first page if($this->opt['bcurrent_item_linked'] || (is_paged() && $this->opt['bpaged_display'])) { //Since we are paged and are linking the root breadcrumb, time to change to the regular template $breadcrumb->set_template($this->opt['Hsearch_template']); //Figure out the hyperlink for the anchor $url = get_search_link(); //Figure out the anchor for the search $breadcrumb->set_url($url); } }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Search page breadcrumb trail filling function’ is closed to new replies.