Support » Plugin: ReOrder Posts within Categories » Problem using reverse order filter

  • Resolved jtbayly

    (@jtbayly)


    I’m attempting to set several categories to display posts in reverse chronological order. (A simple per-category setting to make the default sort order one of the three filter options you’ve got would be great, by the way.)

    Anyway, below is the code for my first attempt. I know the category ID is correct, but nothing is happening either on the sorting page or when viewing the category page.

    add_filter('reorder_posts_within_category_initial_order', 'reverse_order', 10, 3); 
    function reverse_order($reverse, $post_type, $term_id){
      $reverse = true;
      $post_type = "post";
      $term_id = 184;
      return true;
    }

    Could you please let me know what’s wrong with the code, and also clarify where I should see the difference (sorting page, frontend, or both), and whether I need to turn on manual sorting for the category as well as using this filter?

    I’ve tried a bunch of things with this filter and not gotten it to work, but I’m not confident enough I understand it to say this is a bug.

    I appreciate your help.

    P.S. I’m running the version that just came out this morning. (2.0.1, I think?)

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    Your understanding and usage of filters is erroneous. I would suggest that you either take a course in WordPress/PHP development or you hire a developer to understand how filters work. I cannot help you with WP core functionality in this forum.

    add_filter('reorder_posts_within_category_initial_order', 'reverse_order', 10, 3); 
    function reverse_order($reverse, $post_type, $term_id){
      //you can only filter the first attribute passed to a filter callback function.
      //the other attributes are there to help you make the right choice.
      if('post' == $post_type && '184' == $term_id) $reverse = true; 
      return $reverse;
    }
    

    This plugin **only** lets you order posts manually. The filter you are trying to use is for the intially order you see on your admin reorder page. It is a tool to help you sort your posts manually.

    If what you seek is simpy to reverse the chronological order of your posts in the front-end of your site, then you do not need this plugin, you can achieve this very easily with the default funtionality already provided in the WP framework such as a custom query.

    Thank you for your help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problem using reverse order filter’ is closed to new replies.