Home Forums Free Themes Magzimum How to add featured image in search results?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1538
    scorbelli
    Participant

    First of all thanks for this great free theme that I love it. I would just add the featured image in the search results. How should I edit the code? Thanks!

    #1539
    wensolutions
    Keymaster

    Hello @Scorbelli,
    Looks like this issue has already been resolved in this thread: https://wordpress.org/support/topic/featured-image-is-not-found-in-search-results?replies=5

    Kindly post for any further confusion.

    Thanks,

    #1545
    scorbelli
    Participant

    Thanks a lot !
    It perfectly works!

    Actually I have 2 more things to ask maybe there is an answer as well:

    1) How to link the featured image to the post?
    2) How to add some dots after the end of an excerpt ?

    thanks I didnt know if i had to open new topics.

    #1546
    wensolutions
    Keymaster

    Hello @scorbelli,
    Glad to hear that your previous has been resolved 🙂

    Now, to link the featured image to the post, just replacing some codes will do it.

    Replace these lines in content-search.php of child theme:

    <div class="entry-summary">
    		<?php if ( has_post_thumbnail() ): ?>
              <?php the_post_thumbnail( 'medium', array( 'class' => 'aligncenter' ) ); ?>
            <?php endif ?>
    
    		<?php the_excerpt(); ?>
    	</div><!-- .entry-summary -->

    with these:

    <div class="entry-summary">
    		<?php if ( has_post_thumbnail() ): ?>
              <a href="<?php echo get_permalink();?>">
              <?php the_post_thumbnail( 'medium', array( 'class' => 'aligncenter' ) ); ?>
            </a>
            <?php endif ?>
    
    		<?php the_excerpt(); ?>
    	</div><!-- .entry-summary -->

    And for ‘readmore’,
    Just go to Customizer > Themes Options > Blog, and configure the readmore text according to your requirement.

    Hope that helps resolving your issue.

    Thanks!

    #1590
    scorbelli
    Participant

    Thanks alot for the answer! It’s all ok with the read more options. As for the first question, if its not too difficult, I would like to link featured image to url post anywhere especially blog. With your code this happens only in search page. thanks alot and sorry for my many questions.

    #1591
    wensolutions
    Keymaster

    Hello @scorbelli,
    Its not the difficult one. Actually few customization like above will do it. Just copy a file called content.php from parent theme which is inside ‘template-parts‘ folder and paste it inside the same folder of the child theme where you have pasted ‘content-search.php’.

    Now comes the editing part. Open the file (content-search.php from child theme) and find the lines <?php the_post_thumbnail( 'large', array( 'class' => 'aligncenter' ) ); ?>. This line is actually present twice. So, just wrap both of those lines like this:
    <a href="<?php echo get_permalink();?>"> <?php the_post_thumbnail( 'large', array( 'class' => 'aligncenter' ) ); ?></a>

    This will do the trick.

    Try this out. Its easy 🙂

    For any confusion, kindly post here.

    Thanks,

    #1592
    scorbelli
    Participant

    Hello It’s all perfect I have no word to thank you for your great help.

    I wrote my review on wordpress.org of course 5 stars here:
    https://wordpress.org/support/view/theme-reviews/magzimum

    Thanks again and have a nice day!

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