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

Hide published date for Pages

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Hide published date for Pages

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #30694
    Georgergb75Georgergb75
    Participant

    Hi,

    I have found the setting where I can choose whether to show the published date in results.

    However, I was wondering if there is anyway of refining this. I don’t want to show the published date for Pages as this is not really relevant but I do need it for Posts where it is important.

    Is there anyway of altering this?

    Many thanks

    George

    #30700
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi George,

    With a simple custom code it might be doable, by unsetting the date for the page post type results. Using the asp_results hook, something like this:

    add_filter( 'asp_results', 'asp_remove_date_from_pages', 10, 1 );
    function asp_remove_date_from_pages( $results ) {
    	foreach ($results as $k=>&$r) {
    	  	if ( isset($r->post_type) && $r->post_type == 'page' ) {
    			$r->date = '';
    		}
    	}
    
    	return $results;
    }
    #30708
    Georgergb75Georgergb75
    Participant

    Hi Ernest,

    Thank you very much for the advice and responding so quickly.

    Best

    George

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.