Prevent post type "future" for a specific category (1 post)

  1. djhamster
    Posted 1 year ago #

    Hi there! I'm not very familiar with PHP and I'm hoping someone here is willing to help me with solving a problem.
    Currently I have this code in my theme's functions.php:

    function prevent_future_type( $post_data ) {
            if ( $post_data['post_status'] == 'future' && $post_data['post_type'] == 'post' ) {
                    $post_data['post_status'] = 'publish';
            return $post_data;
    add_filter('wp_insert_post_data', 'prevent_future_type');
    remove_action('future_post', '_future_post_hook');

    I have 2 categories on my blog for events and this code enables me to show posts to my visitors with future dates - dates of the events. Now I'd like to add some filter here to bypass the "future status" only for posts in those two specific categories, so that posts in any other category could still get scheduled for publishing.

    I've been trying to add this functionality for the past few hours and got nothing but 50x errors... :) So, can anyone please give me a suggestion on how to achieve what I want?

Topic Closed

This topic has been closed to new replies.

About this Topic