This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

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?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #22087
    webbkkwebbkk
    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.

    #22095
    Ernest MarcinkoErnest 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;
    }
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.