WordPress.org

Forums

Post Types Order
[resolved] 'menu_order' not reordering items (4 posts)

  1. tylerdoornbos
    Member
    Posted 1 year ago #

    I am using the query-based method, and it is not returning my posts in even remotely the same order as they are in the admin. My query is as follows:

    $args = array(
        'post_type' => 'products',
        'orderby'   => 'menu_order',
        'order'     => 'ASC',
        'tax_query' => array(
               array(
    		'taxonomy' => 'collection',
                    'field' => 'id',
                    'terms' => $term_id,
                    )
          )
    );

    I've tried disabling my other plugins, and it hasn't corrected the problem, nor has changing DESC/ASC. Any thoughts are very much appreciated!

    http://wordpress.org/extend/plugins/post-types-order/

  2. nsp-code
    Member
    Plugin Author

    Posted 1 year ago #

    Can you paste here the query request (sql ) ?
    It should work fine, most probably there is another filter somewhere, possible within your theme.

  3. Gustave F. Gerhardt
    Member
    Posted 1 year ago #

    I am having this same issue. How it this resolved?

    SELECT wp_posts.* FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (12) ) AND wp_posts.post_type = 'location' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC

    $tax_args = array(
    	'post_type' => 'location',
    	'numberposts' => -1,
    	'posts_per_page' => -1,
    	'tax_query' => array(
    		array(
    			'taxonomy' => 'location-category',
    			'field' => 'id',
    			'terms' => get_queried_object()->term_id,
    		),
    	),
    	'order' => 'menu_order',
    	'orderby' => 'DESC',
    );
    $loop = new WP_Query($tax_args);
  4. Gustave F. Gerhardt
    Member
    Posted 1 year ago #

    Actually, in my case, as you may see from the code, I had accidentally transposed "order" and "orderby" parameters. Oops. Thank you for this plugin. Working now

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.