• Resolved plavet

    (@plavet)


    I have 2 sites linked with msls, everything works great, but, i have CPT ‘program’, with post type ‘post’ and it works fine when post date is set for today, but if date is set in the future eg. Scheduled, posts dont show up in msls dropdown in wp backend and i cant link them. Basically i have ‘future posts’ visible on page with this code

    function __include_future( $query )
    {
        if ( $query->is_date() || $query->is_single() || $query->is_home() || $query->is_archive() || $query->is_page() || $query->is_tax())
            $GLOBALS[ 'wp_post_statuses' ][ 'future' ]->public = true;
    }
    add_filter( 'pre_get_posts', '__include_future' );

    Is there a way to have scheduled ‘future’ posts show up in msls dropdown in wp backend?

    https://ww.wp.xz.cn/plugins/multisite-language-switcher/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Dennis Ploetner

    (@realloc)

    Hi,

    I’m not sure if it has to do with the fact that I query for posts with the post_status ‘any’ … http://wordpress.stackexchange.com/questions/13484/how-to-get-all-posts-with-any-post-status

    What do you think about that?

    Cheers,
    Dennis.

    Thread Starter plavet

    (@plavet)

    Hi,

    i did some testing, first, plugin works fine for posts, it does show future posts and draft ones too, but only published ones for custom post types, then i added 'post_type' => 'any' on line 25 and on lines 133 and 147 (MslsMetaBoxx.php) overriding current ones, what i get was, getting everything in dropdown for posts, but nothing in dropdown for custom post type, narrowing down, culprit was 'post_type' => 'any' on line 133, then i went like hmmm that is strange lol, and tried adding 'post_status' => 'any' instead of ‘post_type’ => ‘any’, i returned to default values, only added/changed those 2 values, result was no dropdown for custom post type, strange again lol i guess there is a problem with ‘any’ in that array, a bug in wp maybe? Anyway, to conclude I’ve added 'post_status' => array('publish', 'future', 'draft', 'pending'), on line 133 below 'post_type' => $type, (it’s the array for if ( $pto->hierarchical ) statement) and everything works! Dropdown for custom post types now shows everything, still strange though why 'post_type' => 'any' kills the dropdown for custom post type.

    Thread Starter plavet

    (@plavet)

    Reading the link you’ve posted, maybe its best to use get post stati() to get post status, maybe future proof? eg. will work for custom post status too. Just tried it and it works

    if ( $pto->hierarchical ) {
    	$pstat = get_post_stati();
    	$selects .= wp_dropdown_pages(
    		array(
    			'post_type' => $type,
    			'post_status' => $pstat,
    			'selected' => $mydata->$language,
    			'name' => 'msls_input_' . $language,
    			'show_option_none' => ' ',
    			'sort_column' => 'menu_order, post_title',
    			'echo' => 0,
    		)
    	);
    }
    Plugin Author Dennis Ploetner

    (@realloc)

    OK, cool. Thanks for testing that! I will change that in the repository at GitHub.

    Cheers,
    Dennis.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Custom Post Type Scheduled Post’ is closed to new replies.