Load more not working with custom field ordering
-
Hello.
I’m trying to order some posts using a custom field input. I manage to get it to work using this custom code:
function my_pre_get_posts( $query ) { // do not modify queries in the admin if( is_admin() ) { return $query; } // only modify queries for 'formacoes' post type if( is_front_page() && isset($query->query_vars['post_type']) && $query->query_vars['post_type'] == 'formacoes' ) { $query->set('orderby', 'meta_value'); $query->set('meta_key', 'data_inicio'); $query->set('order', 'ASC'); $query->set('meta_value', date('Ymd')); $query->set('meta_compare', '>='); } // return return $query; } add_action('pre_get_posts', 'my_pre_get_posts');
It works for the posts that are showing up, but if I click the load more button it doesn’t assume the custom order.
Can you help find the reason why?
Thanks.
The page I need help with: [log in to see the link]
- The topic ‘Load more not working with custom field ordering’ is closed to new replies.