WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Cant sort posts with custom query (3 posts)

  1. BK_@_UC
    Member
    Posted 3 years ago #

    Nothing will sort using any of the following code, I have tried many other options as well, but these are examples directly from WP, so they should be working... If I change numberposts, it works, but not sort by any option (title, id or ASC, DESC)...

    I am using mostly the second code block below... Any thoughts or similar problems?

    <?php
    $args = array( 'numberposts' => 3, 'order'=> 'ASC', 'orderby' => 'title' );
    $postslist = get_posts( $args );
    foreach ($postslist as $post) :  setup_postdata($post); ?>
    	<div>
    		<?php the_date(); ?>
    		<br />
    		<?php the_title(); ?>
    		<?php the_excerpt(); ?>
    	</div>
    <?php endforeach; ?>

    or

    $loop = new WP_Query('category_name=food-specials&orderby=id&order=DESC');
     	while ( $loop->have_posts() ) : $loop->the_post();
  2. BK_@_UC
    Member
    Posted 3 years ago #

    Oh, I also have "Post Types Order" plugin by NSP CODE active... Im checking if that is blocking my custom queries globally at the post level... Might be it...

  3. BK_@_UC
    Member
    Posted 3 years ago #

    Yup this was the problem, the POST ORDER TYPES plugin was blocking my 'orderby' & 'order' queries... Looks like they want $25 for the advanced version to let me use custom queries again and still have their drag and drop for my admin users... Might be worth it...

Topic Closed

This topic has been closed to new replies.

About this Topic