• Resolved philiprabbett

    (@philiprabbett)


    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);
    		}
    	}

    https://wordpress.org/plugins/nice-search/

    https://wordpress.org/plugins/breadcrumb-navxt/

Viewing 1 replies (of 1 total)
  • Plugin Author John Havlik

    (@mtekk)

    Thanks for reporting this, it is being tracked by this GitHub issue: https://github.com/mtekk/Breadcrumb-NavXT/issues/101

    One thing to note, while testing, it produced invalid URLs for me (always generates the pretty permalink version which I guess isn’t always valid). It’s lined up for the 5.2.1 release,assuming I can figure out why my testbed doesn’t like it.

Viewing 1 replies (of 1 total)
  • The topic ‘Search page breadcrumb trail filling function’ is closed to new replies.