Search results adding to the title

  • gkandylakis
    Participant
    3 years, 9 months ago #20860

    how can i turn off the <b> on the search results? My template uses Bold on all its headers and we get <b>PRODUCT NAME</b> in all results

    wpsolr
    Keymaster
    3 years, 9 months ago #20862

    You cannot, but you can change its style:

    .a_class b {
    font-weight: normal;
    }

    gkandylakis
    Participant
    3 years, 9 months ago #20864

    I tried it and didn’t work. When i tried to copy the structure of the HTML here i noticed that the browser is reading it as <b> and not <b>. When i manually edited the html the problem disappeared.

    gkandylakis
    Participant
    3 years, 9 months ago #20865

    the browser translates it so it got lost so i’m putting spaces between them
    & lt ; b & gt; and not <b>
    The html entities don’t work properly inside an href

    wpsolr
    Keymaster
    3 years, 9 months ago #20867

    Is it solved?

    gkandylakis
    Participant
    3 years, 9 months ago #20869

    no it is not. I can see in the default highlights you are using the following

    <str name=”hl.simple.pre”>& lt;b& gt;</str>
    <str name=”hl.simple.post”>& lt;/b& gt;</str>

    Should i replace the HTML entities?

    wpsolr
    Keymaster
    3 years, 9 months ago #20871

    Where do you see that?

    gkandylakis
    Participant
    3 years, 9 months ago #20873

    wpsolr-pro/wpsolr/core/classes/engines/solarium/admin/conf/4.0/solrconfig.xml:995
    wpsolr-pro/wpsolr/core/classes/engines/solarium/admin/conf/4.0/old/wpsolr-v4/solrconfig.xml:993
    wpsolr-pro/wpsolr/core/classes/engines/solarium/admin/conf/opensolr/4.0/solrconfig.xml:995
    wpsolr-pro/wpsolr/core/classes/engines/redisearch_php/admin/conf/4.0/solrconfig.xml:995
    wpsolr-pro/wpsolr/core/classes/engines/redisearch_php/admin/conf/4.0/old/wpsolr-v4/solrconfig.xml:993
    wpsolr-pro/wpsolr/core/classes/engines/redisearch_php/admin/conf/opensolr/4.0/solrconfig.xml:995

    wpsolr
    Keymaster
    3 years, 9 months ago #20875

    Thanks, but the config file is overridden by the code.

    There is a filter to do that: WPSOLR_Events::WPSOLR_FILTER_HIGHLIGHTING_PREFIX

    An exemple in /wp-content/plugins/wpsolr-pro/wpsolr/core/classes/extensions/premium/class-wpsolr-option-premium.php:

    // No highlighting tags
    add_filter( WPSOLR_Events::WPSOLR_FILTER_HIGHLIGHTING_PREFIX, [
    	$this,
    	'wpsolr_filter_highlighting_prefix'
    ], 10, 1 );
    add_filter( WPSOLR_Events::WPSOLR_FILTER_HIGHLIGHTING_POSFIX, [
    	$this,
    	'wpsolr_filter_highlighting_posfix'
    ], 10, 1 );
    
    /**
    *
    * Update highlightings prefix
    *
    * @return string
    */
    public function wpsolr_filter_highlighting_prefix( $prefix_tag ) {
    
    	return $this->_wpsolr_filter_highlighting_tag( $prefix_tag );
    }
    
    /**
    *
    * Update highlightings postfix
    *
    * @return string
    */
    public function wpsolr_filter_highlighting_posfix( $postfix_tag ) {
    
    	return $this->_wpsolr_filter_highlighting_tag( $postfix_tag );
    }
    
    /**
    *
    * Update highlightings tag
    *
    * @return string
    */
    protected function _wpsolr_filter_highlighting_tag( $tag ) {
    
    	if ( $this->is_replace_admin_post_type_by_wpsolr_query || $this->is_replace_admin_admin_taxonomy_by_wpsolr_query ) {
    		return '';
    	}
    
    	return $tag;
    }
    
    gkandylakis
    Participant
    3 years, 9 months ago #20881

    So what do i need to change to make it work?

    wpsolr
    Keymaster
    3 years, 9 months ago #20882

    return ” in the filters.

    gkandylakis
    Participant
    3 years, 9 months ago #20885

    sorry but i don’t understand what you are saying. Can you explain?

    wpsolr
    Keymaster
    3 years, 9 months ago #20889

    Use the 2 filters in your theme functions.php to return ” instead of ‘<b>’ and ‘</b>’

    • This reply was modified 3 years, 9 months ago by wpsolr.
    gkandylakis
    Participant
    3 years, 9 months ago #20895

    i tried. It’s not overriding the plugin functions

    gkandylakis
    Participant
    3 years, 9 months ago #21230

    I’m getting

    Fatal error: Uncaught Error: Class ‘WPSOLR_Events’ not found

    when i put your code in our function.php

Viewing 15 posts - 1 through 15 (of 19 total)

You must be logged in to reply to this topic.