Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #895266

    How can I leave the blog post in the ASC order only in a category?
    I found this code::

    add_filter('avia_blog_post_query', 'avia_modify_post_grid_query_asc');
    
    function avia_modify_post_grid_query_desc( $query ) {
    $query['orderby'] = 'date';
    $query['order'] = 'ASC';
    return $query;
    }

    But I think this will change the order of the entire site and not just one category.

    • This topic was modified 7 years, 1 month ago by elitontorri.
    #896507

    Hey elitontorri,

    Thank you for using Enfold.

    Use the is_page function to specify the page where you want the filter to be applied.

    // https://developer.wordpress.org/reference/functions/is_page/

    add_filter('avia_blog_post_query', 'avia_modify_post_grid_query_asc');
    function avia_modify_post_grid_query_desc( $query ) {
    	if(is_page(PAGE ID HERE)) {
    		$query['orderby'] = 'date';
    		$query['order'] = 'ASC';
    	}
    	return $query;
    }

    Change the “PAGE ID HERE” text to the actual ID of the page.

    Best regards,
    Ismael

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