Support » Theme: Twenty Twenty » Featured image on Search results (Twenty Twenty theme)

  • Hi

    As normal, this page http://eyeforthelight.com/?s=roam shows results for posts, pages, and products featuring the word ‘roam’. I would like to add the Featured image (or Product image) for each individual product / post / page, as a thumbnail to the left hand side of the text for each result.

    Ideally I would do this with a code snippet but also happy to edit the theme if necessary. Does anyone have any suggestions please?

    Thanks in advance,
    Simon

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Ian

    (@plantprogrammer)

    Hey, Simon, I would suggest making a child theme and duplicating the content.php file within the template-parts folder from the Twenty Twenty theme like in the following image:

    Afterwards, I would modify this following code snippet from the content.php file
    (starting at line 22):

    if ( ! is_search() ) {
    		get_template_part( 'template-parts/featured-image' );
    	}
    

    to:

    get_template_part( 'template-parts/featured-image' );

    So that way you can have your featured images included within your search, as the default code stops the search results from containing any featured images.

    Thread Starter siwillmore

    (@siwillmore)

    Hey Ian

    Thank you so much for this – you’re a life-saver!

    This is now showing the image perfectly, thanks again. One final question please: I would like the Featured image to appear on the left side of the text (on desktop only) as per the following images:
    https://ibb.co/LkBygfd – current
    https://ibb.co/fCRSjVx – desired

    I imagine it is a CSS fix for the
    .featured-media-inner.section-inner.medium
    class so I have added a
    {float:left;}
    but as you can see at
    http://eyeforthelight.com/?s=roam
    and it’s not quite right yet so it looks terrible! How can I fix this please?

    Thanks again
    Simon

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.