ThemeShaper Forums » Thematic


Sort posts with category alphabetically

(2 posts)
  • Started 9 years ago by killtheliterate
  • Latest reply from middlesister
  • This topic is not resolved
  1. Hi all. I'm wondering if anyone can lend a hand with sorting posts alphabetically within the context of a category archive. I've tried using functions.php to filter the posts query, to no avail.

    I've tried several different functions, the one below seems to be closest, though it returns ALL posts when browsing the category

    function alphabetize_category($query) {
    if ( $query->is_category('4'))
    //print "query string:". $query_string;
    //$query = query_posts('?cat=4&orderby=title&order=asc&posts_per_page=-1');
    return $query;
    add_filter('pre_get_posts', 'alphabetize_category');
    Posted 9 years ago #
  2. middlesister

    I think you need to remove the question mark in the beginning of the query in query_posts. Probably the cat variable was not read because of it. I have never filtered pre_get_posts so I don't really know what format it expects. If I wanted to sort a category alphabetically I would use something like

    function alphabetize_category() {
        if ( is_category('4') ) {
    add_filter('thematic_above_categoryloop', 'alphabetize_category');

    But this is certainly not the only way to do it.

    Posted 9 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.