• Resolved moisb

    (@moisb)


    How to make an image attached in the body of the post or the first image of this post (when the post does not have a featured image set up) appear next to the title and description in the search results with wpsolr?

    I want to replace Google CSE with WpSolr, but I can not configure the search results as I did easily in CSE, generating the PageMap data:
    https://support.google.com/customsearch/answer/1628213?hl=en

    Ps: I use the Pro version

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author WPSolr free

    (@wpsolr)

    Hi,

    To add your custom html PageMap data and your image:
    https://www.wpsolr.com/guide/actions-and-filters/search-results-append-html/

    Add a bit of css/js to adapt the visual effect to your need.

    Thread Starter moisb

    (@moisb)

    Thanks for the reply. But I bought the license WPSOLR + GOTOSOLR. From what I understand in the guide, this code snippet should be inserted into the code of “PHP solarium”.
    Do you have an option to create this filter in the functions.php of the theme?

    Plugin Author WPSolr free

    (@wpsolr)

    You can use wpsolr filters in your functions.php.

    Thread Starter moisb

    (@moisb)

    Ok. I use the following code to configure the PageMap for Google CSE. If it’s not too much to ask, would it be possible for you to give me an example of how I could do the same for the WPSOLR inserting a filter in my functions.php?
    I don’t have a lot of programming skills. I can only manage with a few things ??

    <?php if ( is_single() && has_post_thumbnail() ) {
    $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail' );
    $url = $thumb['0'];
      echo "<!--
      <PageMap>
        <DataObject type='thumbnail'>
          <Attribute name='src' value='".$url."'/>
          <Attribute name='width' value='112'/>
          <Attribute name='height' value='90'/>
        </DataObject>
      </PageMap>
      -->";
    } elseif ( is_tax('store') ) {
    global $category;
    $merchant_logo = $GLOBALS['CORE_THEME']['category_icon_'.$category->term_id]; 
        echo "<!--
      <PageMap>
        <DataObject type='thumbnail'>
          <Attribute name='src' value='".$merchant_logo."'/>
          <Attribute name='width' value='112'/>
          <Attribute name='height' value='90'/>
        </DataObject>
         <DataObject type='action'>
          <Attribute name='label' value='".$category->name."'/>
          <Attribute name='url' value='https://www.mywebsite.com/store/".$category->slug."'/>
          <Attribute name='class' value='store'/>
        </DataObject>
      </PageMap>
      -->";
    } elseif ( is_singular( 'coupon_type' )   ) {
        echo "<!--
      <PageMap>
        <DataObject type='thumbnail'>
          <Attribute name='src' value='".catch_that_image()."'/>
          <Attribute name='width' value='112'/>
          <Attribute name='height' value='90'/>
        </DataObject>
      </PageMap>
      -->";
    } else {
      echo "<!--
      <PageMap>
        <DataObject type='thumbnail'>
          <Attribute name='src' value='https://www.mywebsite.com/wp-content/uploads/thumb_posts.png'/>
          <Attribute name='width' value='112'/>
          <Attribute name='height' value='90'/>
        </DataObject>
      </PageMap>
      -->";
    }
    
    ?>
    • This reply was modified 7 years, 9 months ago by moisb.
    Plugin Author WPSolr free

    (@wpsolr)

    Please use our Zendesk PRO support: https://www.wpsolr.com/

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Show post attached image on search result’ is closed to new replies.