• Resolved newash

    (@newash)


    Hey hijiri,

    I had this issue with the orderby like others had, with the latest version where it’s supposed to work.

    Then I looked into your code.

    Was there any specific reason using the global $args to figure out if there was an orderby set on the outside? Why weren’t the $wp_query->get('orderby') an the $wp_query->get('order') good for that? If these ordering settings are not coming from the main query on a page or anything special is used to set the order of the main query the global $args doesn’t match what is set in the query — resulting your plugin overwriting the original setting.

    So if you think your plugin could work by reading the Query object people here probably wouldn’t need to do hacks to disable your – otherwise really good – plugin.

    https://www.ads-software.com/plugins/intuitive-custom-post-order/

Viewing 15 replies - 1 through 15 (of 18 total)
  • Thread Starter newash

    (@newash)

    OK, more specifically I was thinking about this in the hicpo_pre_get_posts function:

    if ( $active ) {
    	if ( !$wp_query->get( 'orderby' ) ) {
    		$wp_query->set( 'orderby', 'menu_order' );
    	}
    	if ( !$wp_query->get( 'order' ) ) {
    		$wp_query->set( 'order', 'ASC' );
    	}
    }

    Is there any chance you would check it at see if it works?

    Hey Newash

    I used your code above and it corrects the behaviour of the plugin just applying order wherever it wants to.

    I have uploaded my version of the file here:

    https://gist.github.com/AnrietteC/d3bf514128dc7ebb1c29

    Thanks for you input!

    Thread Starter newash

    (@newash)

    Hey Anriette,

    Thanks for the feedback, now it’s working at least for the two of us. ??

    I haven’t created a snipplet myself, but looking at yours made me wonder if the “playing safe” like if ( isset( $args ) ) ... part is necessary at all. I mean in theory.
    Should $wp_query already contain what’s in $args at that point already?

    I meant this question mainly for the original developer, what do you think hijiri?

    Kenny

    (@puns0steel)

    Thanks @newash and @anriettec! I used @anriettec’s version of the file from github and it worked.

    I did have to go to my custom post type in wordpress and drag/drop one of them, and then the plugin’s sorting worked correctly.

    My custom query orderby and order is now working as expected. Thanks so much you two, and @hijiri of course!

    jefffassnacht

    (@jefffassnacht)

    Thank you @newash and @anriettec. This solved my problem, too!

    Employed @anriettec’s code and it works great. Now I can use JC Submenu to auto-populate submenus and the Intuitive Custom Post Order order does not conflict with the submenu order.

    Plugin Author hijiri

    (@hijiri)

    hi, there.

    Thanks for the feedback and your code.
    I want adopt it.

    thanks!

    Plugin Author hijiri

    (@hijiri)

    Hi, there.

    I adopt this code in ver.3.0.3.
    Please try this.

    Thanks.

    Thread Starter newash

    (@newash)

    Hi hijiri,

    For the first look, it seems to be OK.
    Thanks for the fix!

    I’m curious though: should $wp_query already contain what’s in $args at the point of calling hooks for pre_get_posts? Is it triggered anywhere else then here?: wp-includes/query.php/get_posts()

    Cheers

    Plugin Author hijiri

    (@hijiri)

    Hi newash.

    Likely there hints in there to solve the biggest problem facing.

    Thanks.

    Plugin Author hijiri

    (@hijiri)

    Hi, there.

    updated to ver.3.0.4.
    Please try this.

    note:
    Your Query which uses the ‘order’ or ‘orderby’ parameters is preferred.
    In order to prefer the parameters of your query, You must use the ‘WP_Query()’ or ‘query_posts()’. Excluded ‘get_posts()’.

    Thanks.

    Hi

    Do some of you guys know how to display the oldest posts first? I can not get it to work with the general orderby and order query.

    Thanks

    Thread Starter newash

    (@newash)

    Hey mrseneca,

    Does WP_Query('orderby=date&order=ASC') not work?

    It works. But is there a way where I can reverse my admin backend?

    Thread Starter newash

    (@newash)

    You mean: by default?
    This was the first in my Google search result list:
    https://www.ads-software.com/support/topic/sort-pages-by-date-in-admin-by-default?replies=4
    Not the nicest with that global variable, but seems to be doing the job.

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘orderby issue: possible general solution’ is closed to new replies.