Can’t order posts using get_posts because of plugin weird logic
-
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)
Viewing 6 replies - 1 through 6 (of 6 total)
- You must be logged in to reply to this topic.