Forums › Forums › Search & Filter Pro › How to show post date on search results?
- This topic has 3 replies, 2 voices, and was last updated 10 years, 6 months ago by Ross.
-
Anonymous(Private) May 20, 2014 at 12:15 pm #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(Private) May 20, 2014 at 12:28 pm #764Hey 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 closingendwhile
– see the docs for more info…Let me know how you get on!
Anonymous(Private) May 20, 2014 at 1:00 pm #765Hi & 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!
-
AuthorPosts