Conversation
supportHey Team, I’m encountering an issue with excluding standard posts from custom re-ordering. Despite using the following code, the order of some normal posts on the frontend still appears incorrect: add_filter('pto/posts_orderby/ignore', 'theme_pto_posts_orderby', 10, 3); function theme_pto_posts_orderby($ignore, $orderBy, $query) { $post_type = isset($query->query_vars['post_type']) ? $query->query_vars['post_type'] : ''; if ( (is_string($post_type) && $post_type == 'post') || (is_array($post_type) && in_array('post', $post_type)) ) { $ignore = true; } return $ignore; } Could you help me identify what might be causing this issue? Any insights would be greatly appreciated. Thanks a lot! Judit
Hi, I don’t see any issue in your code, the customised order should not change for the ‘post’ object type. The filter is also explained at https://www.nsp-code.com/ignore-sort-apply-for-certain-query-on-post-types-order/ Try moving the code to a custom file on your /wp-content/mu-plugins/ Also make sure the query is actually including the post type you looking for. You could just print_r the object to see all properties. Thanks
Hi, I don’t see any issue in your code, the customised order should not change for the ‘post’ object type. The filter is also explained at https://www.nsp-code.com/ignore-sort-apply-for-certain-query-on-post-types-order/ Try moving the code to a custom file on your /wp-content/mu-plugins/ Also make sure the query is actually including the post type you looking for. You could just print_r the object to see all properties. Thanks