Jump to content
Sign in to follow this  
keithadler

Cannot orderby posts

Recommended Posts

keithadler

No matter what I do, no matter what I try I cannot get this code to orderby anything other than the order the posts were entered in PlatformPro. Please advise:

# Query
	query_posts('cat=28&orderby=title&order=ASC');
	
	# Iterate
	while(have_posts())
	{
	
	# Populate
	the_post();
	
	# Show title, excerpt
	echo '<tr><td>';
	the_title();
	echo '</td><td>';
	the_excerpt();
	echo '</td></tr>';
	
	}
	
	# Reset query
	wp_reset_query();

Share this post


Link to post
Share on other sites
keithadler

This is really weird, but I solved the problem by adding a custom filter. Removing all of the current filters had no effect ... but this works:

    # Vars
	    global $post;
	
	    # Build
	    $args = array(
	        'numberposts'     => -1,
	        'category'        => 28,
	        'post_type'       => 'post',
	        'post_status'     => 'published' );
	
	    # Clear
	    add_filter('posts_orderby', 'post_title ASC' );
	
	    # Query
	    $tagposts = get_posts($args);
	
	    # Iterate
	    foreach($tagposts as $post) :
	
	    # Populate
	    setup_postdata($post);
	
	    # Show title, excerpt
	    echo '<tr><td>';
	    the_title();
	    echo '</td><td>';
	    the_excerpt();
	    echo '</td></tr>';
	
	    endforeach;
	
	    # Order
	    function title_alphabetical( $orderby )
	    {
	      return $orderby;
	    }

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×