Forums Forums Search & Filter Pro How to show post date on search results?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Anonymous
    #763

    I installed your Search & Filter today – it’s working great… thanks! ๐Ÿ™‚

    I just have a query that perhaps you can help with. When I do a search and a list of posts is shown, there isn’t a post date on them. Do you know how I would get that added please? I have set the ‘custom template’ to search.php because without this, I sometimes got a blank page if no results were found.

    Many thanks!

    Ross Moderator
    #764

    Hey Ellen ๐Ÿ™‚

    This just sounds like you need to make a small modification to your template file.

    First, open up the template file in your theme directory that is being used for the search results (by default this is search.php)…

    Then you need to add in a line of code to add the date (see docs for more customisation):

    <p>Date posted: <?php the_date(); ?></p>
    

    Make sure you place this somewhere inside the loop (after the while (have_posts()) and before the closing endwhilesee the docs for more info

    Let me know how you get on!

    Anonymous
    #765

    Hi & thanks for your quick reply! After a bit of digging I found my search.php actually just points to content-search.php. Adding the_date() in there did display the date for some of the posts, but not others. A quick Google search revealed that the_date() only displays the date for the 1st post where multiple posts were posted on the same day. get_the_date() solves this issue. So all sorted now, many thanks for pointing me in the right direction!

    Ross Moderator
    #766

    Glad you got it working ๐Ÿ™‚

Viewing 4 posts - 1 through 4 (of 4 total)