M
M
Mikhail2021-08-15 14:03:53
WordPress
Mikhail, 2021-08-15 14:03:53

How to make posts with future status available in the public part?

How to make posts with future status available in the public part?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail, 2021-08-15
@Mishaermolaev

Found the answer
wordpress.stackexchange.com/a/314188

add_action( 'pre_get_posts', 'joesz_include_future_posts' );
function joesz_include_future_posts( $query ) {

    if ( $query->is_main_query() &&
        ( $query->query_vars['post_type'] == 'accounts' || // for single
            is_post_type_archive( 'accounts' ) ) ) { // for archive

        $query->set( 'post_status', array( 'future', 'publish' ) );
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question