I'm having an issue on a pre_get_posts action that, I guess, is caching the request, ignoring the update_post_meta_cache set to false.
If the CPT is empty (no post at all) and I programmatically (or even manually) fill it, I can't see any post but the post count is correctly updated.
Then if I comment the add action row, reload the cpt page, I can see al posts and if I remove the comment (so the system will now elaborate the add_action) everything works as it should.
At first I thought it was a caching problem, but I'm having this issue even with the update_post_meta_cache set on false and I'm on a developing server so it has no cache at all.
What I'm missing? Thank you!
add_action( 'pre_get_posts', 'my_npk_overload_orderby' );
function my_npk_overload_orderby( $query ) {
if( ! is_admin() ){
return;
}
if ( isset( $_GET["post_type"] ) &&
$_GET["post_type"] == 'articoli-da-fare' &&
!strpos($_SERVER["REQUEST_URI"],'post-new.php') )
{
$orderby = $query->get( 'orderby');
$query->set('meta_key','npk_overload_status');
$query->set('orderby',"meta_value");
$query->set('order', 'ASC');
$query->set('update_post_meta_cache',false);
}
}