Home › Forums › Free Themes › Magzimum › How to add featured image in search results?
- This topic has 6 replies, 2 voices, and was last updated 8 years, 9 months ago by scorbelli.
-
AuthorPosts
-
February 20, 2016 at 11:11 pm #1538scorbelliParticipant
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!
February 20, 2016 at 11:19 pm #1539wensolutionsKeymasterHello @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=5Kindly post for any further confusion.
Thanks,
February 21, 2016 at 3:21 am #1545scorbelliParticipantThanks 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.
February 21, 2016 at 3:52 am #1546wensolutionsKeymasterHello @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!
February 21, 2016 at 6:14 am #1590scorbelliParticipantThanks 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.
February 21, 2016 at 6:36 am #1591wensolutionsKeymasterHello @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,
February 21, 2016 at 7:47 am #1592scorbelliParticipantHello 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/magzimumThanks again and have a nice day!
-
AuthorPosts
- You must be logged in to reply to this topic.