Hide published date for Pages

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

This topic contains 2 replies, has 2 voices, and was last updated by Georgergb75 Georgergb75 3 years, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #30694
    Georgergb75
    Georgergb75
    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 Marcinko
    Ernest 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;
    }
    Best,
    Ernest Marcinko

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


    #30708
    Georgergb75
    Georgergb75
    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.