WordPress.org

Ready to get started?Download WordPress

Forums

Post Types Order
Sort not working on SOME custom post types (8 posts)

  1. sdaponte
    Member
    Posted 6 months ago #

    Hi there,

    I'm using this plugin in conjunction with the Types plugin. I have 4 custom post types, some of which are ordering as expected and some of which are not.

    Here is my code for an example that is NOT sorting:

    <?php $args = array( 'post_type' => 'side_feature', 'posts_per_page' => 3, 'order'=>'ASC', 'hierarchical' => false);
    	$loop = new WP_Query( $args );
    	while ( $loop->have_posts() ) : $loop->the_post(); ?>
            <li>
    		<!-- my code -->
    	</li>
    <?php endwhile; ?>

    I'm using the exact same code to sort my homepage billboards, which is working fine, so I'm a little perplexed here.

    Thanks in advance for your help!

    https://wordpress.org/plugins/post-types-order/

  2. sdaponte
    Member
    Posted 6 months ago #

    REVISION:

    It appears the sort is somewhat working, but is behaving strangely. Again, my homepage_billboards custom type is working exactly as expected. I have two other post types that are behaving differently.

    I have my items sorted as so:
    (1)Lorem
    (2)Ipsum
    (3)Dolor

    And they appear on my site as follows:
    (3)Dolor
    (1)Lorem
    (2)Ipsum

    Also, if I change my 'order' from 'ASC' to 'DESC' it has no affect.

  3. nsp-code
    Member
    Plugin Author

    Posted 6 months ago #

    Try including 'orderby' => 'menu_order' within your query arguments.

  4. sdaponte
    Member
    Posted 6 months ago #

    Thanks for the response - unfortunately that did not make any change.

    I've actually tried every option for the orderby:
    http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
    Section 5.11

    None of which seemed to have any affect on the ordering.

  5. nsp-code
    Member
    Plugin Author

    Posted 6 months ago #

    Try turning off the Autosort. Also possible there is another plugin which create some sort of conflict, try to de-activate.

  6. tdgu
    Member
    Posted 6 months ago #

    What's this argument for 'hierarchical' => false ?

  7. sdaponte
    Member
    Posted 6 months ago #

    Thanks tdgu - I had read on some other forum responses that setting the hierarchical setting to false did the trick for most people, however my custom post type is already specifying a non-hierarchical relationship, so specifying it here again is in fact redundant. That being said switching it to true, or removing it entirely both had no affect.

    nsp-code: Not sure where this autosort you speak of is set? Would this be a setting in the custom post type or is this an argument I can pass within my query? If so can you let me know what the proper syntax is? I've tried 'autosort'=>false and 'auto_sort' => false

    In re. to your suggestion about plugins - the only 3 plugins I'm using are Types, Post Types Order, and Contact Form 7.

  8. nsp-code
    Member
    Plugin Author

    Posted 6 months ago #

    Sorry i meant within the plugin settings.
    The 'order' query argument as ASC or DESC should really change something in the results list

Reply

You must log in to post.

About this Plugin

About this Topic