Tagged: 

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

    I’m currently using this code, which works well.

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

    However, I only want it on a specific page or module on a page.

    Is this possible?

    #1339485

    Hey Jad,

    Thank you for the inquiry.

    You can use the is_page conditional function to exclude the other pages and apply the changes to a specific page.

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

    Example:

    
    function avia_modify_post_grid_query_asc( $query ) {
    	if(is_page(123)) {
    		$query['orderby'] = 'title';
    		$query['order'] = 'ASC';
    	}
    
    	return $query;
    }
    add_filter('avia_blog_post_query', 'avia_modify_post_grid_query_asc');
    

    The filter above will only change the query on the page with the ID 123.

    Best regards,
    Ismael

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