Can I display published date and last update in search result?

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Can I display published date and last update in search result?

This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 5 years ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #22087
    webbkk
    webbkk
    Participant

    Dear Support Team,

    I want to display published date and last update in search result.
    Could you guide me for do this?

    Thank you.

    Attachments:
    You must be logged in to view attached files.
    #22095
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    Sure, this is only possible via using a custom code. Try this custom code in the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

    add_filter('asp_results', 'asl_modified_date', 10, 1);
    function asp_modified_date($results) {
       foreach ($results as $k=>&$r) {
          $dates = 
            'Published: ' . get_the_date('', $r->id) . '<br>' . 
            'Modified: ' . get_the_modified_date('', $r->id) . '<br>';
          $r->content = $dates . $r->content;
       }
       return $results;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


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

You must be logged in to reply to this topic.