• Resolved kikky7

    (@kikky7)


    I am using default Post with your plugin and it works fine, until I need to use get_posts, which has suppress_filters included and set to true as default (but even setting it to false does nothing because of your very weird logic in scporder_pre_get_posts function). And there are no actions or filters included to override this code.

    if ( isset( $wp_query->query['suppress_filters'] ) ) {
    				if ( $wp_query->get( 'orderby' ) == 'date' ) {
    					$wp_query->set( 'orderby', 'menu_order' );
    				}
    				if ( $wp_query->get( 'order' ) == 'DESC' ) {
    					$wp_query->set( 'order', 'ASC' );
    				}
    			} else {
    				if ( ! $wp_query->get( 'orderby' ) ) {
    					$wp_query->set( 'orderby', 'menu_order' );
    				}
    				if ( ! $wp_query->get( 'order' ) ) {
    					$wp_query->set( 'order', 'ASC' );
    				}
    			}

    Why do you check if suppress_filters is set? Why not checking the value? It’s always set with get_posts, meaning get_posts can’t be used with this plugin to change the order so I must use ugly WP_Query to get my posts in different order…

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter kikky7

    (@kikky7)

    I would update the code with something like this, meaning if suppress_filters is true then include custom orderby if exists:

    $suppressFilters = $wp_query->query['suppress_filters'] ?? false;
    
    			if ( !$suppressFilters ) {
    				if ( $wp_query->get( 'orderby' ) == 'date' ) {
    					$wp_query->set( 'orderby', 'menu_order' );
    				}
    				if ( $wp_query->get( 'order' ) == 'DESC' ) {
    					$wp_query->set( 'order', 'ASC' );
    				}
    			} else {
    				if ( ! $wp_query->get( 'orderby' ) ) {
    					$wp_query->set( 'orderby', 'menu_order' );
    				}
    				if ( ! $wp_query->get( 'order' ) ) {
    					$wp_query->set( 'order', 'ASC' );
    				}
    			}
    Thread Starter kikky7

    (@kikky7)

    get_terms() custom orderby is also ignored with your plugin…

    Plugin Author Razvan Aldea

    (@raldea89)

    Hello @kikky7 ,

    You could have used the get_posts function with the “orderby” argument set and it would have bypassed the plugin’s functionality.

    Regarding the check, you are right, I’ll add a ticket and will be fixed most probably in the next update.

    Warmly,
    Razvan

    Thread Starter kikky7

    (@kikky7)

    I did use orderby argument, that’s why I reported it, for me it’s not working with get_posts and get_terms functions.

    I tried every combination, with suppress_filters, without it, with true, with false, with orderby, without orderby, etc. I don’t think I missed any case.

    Plugin Support beatrice12

    (@beatrice12)

    Hi @kikky7,

    There is an open ticket regarding this issue and it will be solved in our future update. Apologies for the trouble and headache!

    Warm regards,

    Beatrice.

    Plugin Support beatrice12

    (@beatrice12)

    This topic will be marked as resolved as we have an open ticket on GitHub regarding this. Please keep in mind that the ‘resolved’ status is only for this support thread, not the issue on GitHub.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.