0

I recently updated Wordpress to 5.0.3 and I got a problem on post__in, in particular I have this $query:

$query = array(
        'post_type'             => array('post'),
        'showposts'             => $instance['posts_num'],
        'cat'                   => $instance['posts_cat_id'],
        'ignore_sticky_posts'   => true,
        'orderby'               => $instance['posts_orderby'],
        'order'                 => 'dsc',
        'date_query' => array(
            array(
                'after' => $instance['posts_time'],
            ),
        ),
        'post__in' => array()
    );

if(!empty($instance["posts_specific"]))
{
    $query["post__in"] = explode(',', $instance["posts_specific"]);
}

for some reasons the widget doesn't display anymore the post specified in posts_specific, eg: 5435 (before all this mechanism worked).

I pasted here the full class. What is changed? I can't see anything reported in the official changelog.

4
  • What is the out put of print_r( explode(',', $instance["posts_specific"] ) ); or print_r( $query["post__in"] );? – Qaisar Feroz Mar 16 '19 at 8:45
  • @QaisarFeroz this return an array with the id of the post, something like: (5536, 285, 789)... if you check the full code at the bottom of the question (pastebin), this: have_posts return false, but before the update all worked well.. don't know what's happened – sfarzoso Mar 16 '19 at 9:06
  • I copied your code into my local setup and it runs without fail. I am using latest WP 5.1.1. So, there no problem with your code. There might be some plugin or theme functionality ,causing the problem. Deactivate all plugins and then re-activate one by one to find the culprit. – Qaisar Feroz Mar 16 '19 at 11:06
  • @QaisarFeroz I disabled all the plugins and still same problem, I repeat: before worked, after wp update not work. I can't update yet to 5.1.1 – sfarzoso Mar 16 '19 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.