• robahas

    (@robahas)


    Hi

    When I filters the posts list in the admin side by category, I get the list of relevant posts. However, Each post title is a mess of spans around each individual letter of the title, like this:

    <span class=”search-term”></span>C<span class=”search-term”></span>h<span class=”search-term”></span>a<span class=”search-term”></span>i<span class=”search-term”></span>r<span class=”search-term”></span> <span class=”search-term”></span>9<span class=”search-term”></span> <span class=”search-term”></span>W<span class=”search-term”></span>o<span class=”search-term”></span>o<span class=”search-term”></span>d<span class=”search-term”></span>s<span class=”search-term”></span>t<span class=”search-term”></span>o<span class=”search-term”></span>n<span class=”search-term”></span>e<span class=”search-term”></span> <span class=”search-term”></span>P<span class=”search-term”></span>i<span class=”search-term”></span>z<span class=”search-term”></span>z<span class=”search-term”></span>a<span class=”search-term”></span> <span class=”search-term”></span>&<span class=”search-term”></span>#<span class=”search-term”></span>0<span class=”search-term”></span>3<span class=”search-term”></span>8<span class=”search-term”></span>;<span class=”search-term”></span> <span class=”search-term”></span>B<span class=”search-term”></span>a<span class=”search-term”></span>r<span class=”search-term”></span>

    Any ideas? Thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter robahas

    (@robahas)

    I fixed this within a bout a minute posting. I had borrowed the following code to highlight search terms on the front end, but it turns out it affected the back end as well:

    //Highlight Search Terms
    function highlight_search_term($text){
        if(is_search()){
    		$keys = implode('|', explode(' ', get_search_query()));
    		$text = preg_replace('/(' . $keys .')/iu', '<span class="search-term"></span>', $text);
    	}
        return $text;
    }
    add_filter('the_excerpt', 'highlight_search_term');
    add_filter('the_title', 'highlight_search_term');
Viewing 1 replies (of 1 total)
  • The topic ‘Post filtering produces individual letters wrapped in spans’ is closed to new replies.