• Resolved cordial666

    (@cordial666)


    hey,

    Firstly, thanks for the plugin, it is something I really need! However, it is not working for me in a reordering sense on the front end (I can reorder fine on the backend). I’ve tried adding orderby explicitly in my query and setting override on as per the FAQ #10 explaination. Here is my query –

    $term = get_term_by( ‘slug’ , get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) );
    $posts_array = get_posts(
    array(
    ‘posts_per_page’ => 40,
    ‘post_type’ => ‘speaker’,
    ‘tax_query’ => array(
    ‘orderby’ => ‘menu_order’,
    ‘sort_order’ => ‘asc’,
    array(
    ‘taxonomy’ => ‘speaker_category’,
    ‘field’ => ‘term_id’,
    ‘terms’ => $term->term_id
    )
    )
    )
    );

    Originally it didn’t have orderby and the sorting didn’t work. In FAQ #10, there is a line –
    //check this is the correct query
    if($wp_query….){
    $override = true;
    }
    What should $wp_query be checking against here to make sure it is the right query?

    I’ve also tried the second part of FAQ#10 to no avail by doing –

    add_filter(‘reorderpwc_filter_multiple_post_type’, ‘filter_my_ranked_post_type’, 10, 4);
    function filter_my_ranked_post_type($type, $post_types, $taxonomy, $wp_query){
    /* String $type post type to filter.
    * String $post_types post types associated with taxonomy.
    * String $taxonomy being queried.
    * WP_Query $wp_query query object. */
    if(‘categories’ == $taxonomy && in_array(‘speakers’,$post_types)) $type = ‘speakers’;
    return $type;
    }

    Is this right (assuming ‘categories’ is the taxonomy name and ‘speakers’ is the custom post type?

    • This topic was modified 4 years, 10 months ago by cordial666.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter cordial666

    (@cordial666)

    nb – I can’t see any JS errors in the console when I drag items / reorder. I presume save is occuring after you drag? I can’t see a save button anywhere..

    I am using Version 2.6.1 of the plugin

    • This reply was modified 4 years, 10 months ago by cordial666.
    Plugin Author Aurovrata Venet

    (@aurovrata)

    I’ve tried adding orderby explicitly in my query and setting override on as per the FAQ #10 explaination.

    you’re getting these mixed up. ‘orderby’ is a query attribute to specific the sorting parameter for your query, eg orderby published date or some meta field or the title of your posts….

    The override functionality provided in v2.6 is to explicitly override that attribute.

    Hence setting the attribute and enabling the override, simply renders your orderby effort void.

    Here is my query –

    
    $posts_array = get_posts(
      array(
        ‘posts_per_page’ => 40,
        ‘post_type’ => ‘speaker’,
        ‘tax_query’ => array(
          ‘orderby’ => ‘menu_order’,
          ‘sort_order’ => ‘asc’,
          array(
            ‘taxonomy’ => ‘speaker_category’,
            ‘field’ => ‘term_id’,
            ‘terms’ => $term->term_id
          )
        )
      )
    );

    so it looks like your issue if related to the fact that you are using a custom query get_posts which sets the suppress_filters attribute to true by default, as detailed in the first part FAQ 10.

    So you need to explicitly set the suppress_filter to false in your custom query, and you can removed the orderby directive,

    
    $posts_array = get_posts(
      array(
        ‘posts_per_page’ => 40,
        ‘post_type’ => ‘speaker’,
        'suppress_filters' => false,
        ‘tax_query’ => array(
          array(
            ‘taxonomy’ => ‘speaker_category’,
            ‘field’ => ‘term_id’,
            ‘terms’ => $term->term_id
          )
        )
      )
    );

    NB: ‘field’ need to be set to ‘id’ and not ‘term_id’

    sorry, ignore that last sentence.

    • This reply was modified 4 years, 10 months ago by Aurovrata Venet. Reason: 'field' need to be set to 'id' and not 'term_id'
    • This reply was modified 4 years, 10 months ago by Aurovrata Venet. Reason: wrong field value
    Thread Starter cordial666

    (@cordial666)

    hey,

    Thank you so much for taking the time to reply and in such detail too. That has indeed fixed the issue (interestingly I also need to override the orderby tickbox, even though I’ve removed it from the query).

    Thanks again
    david

    Plugin Author Aurovrata Venet

    (@aurovrata)

    Thank you so much for taking the time to reply and in such detail too

    do leave a review when you have a moment to spare.

    I also need to override the orderby tickbox

    Indeed, because by default the ‘orderby’ is set to ‘date’

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Not working (sorry) – tried the FAQ workarounds’ is closed to new replies.