Viewing 4 posts - 1 through 4 (of 4 total)
-
AuthorPosts
-
January 10, 2014 at 12:58 am #207718
Hi,
Anyone knows how to sort posts in category/archive in alphabetical order?Thanks
MJanuary 10, 2014 at 7:17 am #207836Hey motylanogha!
Edit config-templatebuilder > avia-shortcodes > blog.php, find this code on line 297:
$query = array( 'paged' => $page, 'posts_per_page' => $params['items'], 'offset' => $params['offset'], 'post__not_in' => (!empty($no_duplicates)) ? $avia_config['posts_on_current_page'] : array(), 'tax_query' => array( array( 'taxonomy' => $params['taxonomy'], 'field' => 'id', 'terms' => $terms, 'operator' => 'IN'))); } else { $query = array( 'paged'=> $page, 'posts_per_page' => $params['items'], 'offset' => $params['offset'], 'post__not_in' => (!empty($no_duplicates)) ? $avia_config['posts_on_current_page'] : array(), 'post_type' => $params['post_type']); }
Replace it with:
$query = array( 'paged' => $page, 'posts_per_page' => $params['items'], 'orderby' => 'name', 'order' => 'ASC', 'offset' => $params['offset'], 'post__not_in' => (!empty($no_duplicates)) ? $avia_config['posts_on_current_page'] : array(), 'tax_query' => array( array( 'taxonomy' => $params['taxonomy'], 'field' => 'id', 'terms' => $terms, 'operator' => 'IN'))); } else { $query = array( 'paged'=> $page, 'posts_per_page' => $params['items'], 'orderby' => 'name', 'order' => 'ASC', 'offset' => $params['offset'], 'post__not_in' => (!empty($no_duplicates)) ? $avia_config['posts_on_current_page'] : array(), 'post_type' => $params['post_type']); }
Refer to this link for more order parameters: http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
Best regards,
IsmaelJanuary 10, 2014 at 8:23 pm #208149Thanks Ismael but I can see no affect.
I’ve added the following action to functions.php which made me happy:
function order_category_archives( $query ) { if ( is_category() && $query->is_main_query() ){ // is_category() can specify a category, if necessary $query->set( 'orderby', 'title' ); $query->set( 'order', 'ASC' ); } } add_action( 'pre_get_posts', 'order_category_archives' );
January 11, 2014 at 6:13 am #208332 -
AuthorPosts
Viewing 4 posts - 1 through 4 (of 4 total)
- The topic ‘Listing blog posts in alphabetical order’ is closed to new replies.