Scheduled custom post type didn't publish

Hi support,

I have created a custom post type but the scheduling function didn't work.
Default post type schedule function work as well but my custom post type is not.

My wp-config.php :
define('DISABLE_WP_CRON', 'true':wink:;
define('WP_CRON_LOCK_TIMEOUT', '10':wink:;

Server cron job setting :
*/5 * * * * wget -q -O - http://www.she.com/wp-cron.php?doing_wp_cron

Is it a bug?

  • Rupok

    Hi shecom,

    I just created a custom post type with our plugin - CustomPress. Then created a post and scheduled that. It was posted just on time without any issue. So this is your site specific issue.

    As you have this constant in your wp-config.php file, it's disabling the default WordPress cron job. Can you please remove or comment out the following line from your wp-config.php file?
    define('DISABLE_WP_CRON', 'true');
    You mentioned that you are using server-side cron but can you try using the native one and check if this resolves your issue?

    Moreover, how did you register your custom post type? There might be configuration error while registering that custom post type, I'm not sure though. If you tell us full details, it will help us to give you proper guidance.

    I could tell you better about the issue if I could see it live, check your current configuration and make some tests on your site. Would you mind allowing Support Access so we can have a closer look at this?

    To enable support access you can follow this guide here:
    http://premium.wpmudev.org/manuals/wpmu-dev-dashboard-enabling-staff-login/

    Another thing, your site seems to be a live site. Is it ok if we do test in that site? For example, I may install CustomPress temporarity to create another custom post type to check the issue. Is that okay? If yes, can you please create a complete backup of your site so we can always revert back to current state if anything goes wrong. If no, can you please create a staging server where we can test this and find the reason behind it? You will get more idea regarding creating staging sites from these articles:
    https://premium.wpmudev.org/blog/wordpress-staging-environment/
    https://premium.wpmudev.org/blog/set-up-staging-site-cloner/

    Please let us know if you have any confusion. We will be glad to help further.

    Have a nice day. Cheers!
    Rupok

  • shecom

    Hi Rupok,

    I just removed 'define('DISABLE_WP_CRON', 'true');' and tried to schedule custom post but still not working.

    I have grant permission for access, please login use below account I created if wpmu dashboard not working.
    login url : http://facelift.she.com/shecms/
    login : **********
    pass : **********

    After login, please click 'Super Banners' from left siderbar which is custom post type I created and its not working with scheduling function.

    Attached code is my register custom post syntax which placed in my custom plugin not theme's function.

    Thanks

    ####################
    attachment seems denied, please see below

    <?php
    
    /*   custom post type     */
    add_action( 'init', 'superBanner');
    add_filter( 'post_updated_messages', 'superBannerUpdatedMessages');
    add_filter( 'user_can_richedit', 'disableRichEdit');
    add_filter('quicktags_settings', 'disableTextEditorQuickTag');
    
    #########custom post type begin#########
    
    function superBanner() {
    
        $labels = array(
            'name'               => _x( 'SuperBanner ', 'post type general name' ),
            'singular_name'      => _x( 'SuperBanner', 'post type singular name' ),
            'add_new'            => _x( 'Add New', 'Super Banner' ),
            'add_new_item'       => __( 'Add New' ),
            'edit_item'          => __( 'Edit Super Banner' ),
            'new_item'           => __( 'New Super Banner' ),
            'all_items'          => __( 'All Super Banners' ),
            'view_item'          => __( 'View Super Banner' ),
            'search_items'       => __( 'Search Super Banner' ),
            'not_found'          => __( 'No super banners found' ),
            'not_found_in_trash' => __( 'No super banners found in the Trash' ),
            'parent_item_colon'  => '',
            'menu_name'          => 'Super Banners'
        );
        $args = array(
            'labels'        => $labels,
            'description'   => 'Holds our super banners specific data',
            'public'        => true,
            'menu_position' => 5,
            'supports'      => array( 'title', 'editor', 'thumbnail', 'excerpt', 'author'),
            'has_archive'   => true,
            'taxonomies' => array( 'category'),
        );
        register_post_type( 'super-banner', $args );
    }
    
    function superBannerUpdatedMessages( $messages ) {
      global $post, $post_ID;
      $messages['super_banner'] = array(
        0 => '',
        1 => sprintf( __('Super Banner updated. <a href="%s">View banner</a>'), esc_url( get_permalink($post_ID) ) ),
        2 => __('Custom field updated.'),
        3 => __('Custom field deleted.'),
        4 => __('Super Banner updated.'),
        5 => isset($_GET['revision']) ? sprintf( __('Super Banner restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
        6 => sprintf( __('Super Banner published. <a href="%s">View banner</a>'), esc_url( get_permalink($post_ID) ) ),
        7 => __('Super Banner saved.'),
        8 => sprintf( __('Super Banner submitted. <a target="_blank" href="%s">Preview banner</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
        9 => sprintf( __('Super Banner scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview banner</a>'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
        10 => sprintf( __('Super Banner draft updated. <a target="_blank" href="%s">Preview banner</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
      );
      return $messages;
    }
    
    function superBannerCategory() {
        // Add new taxonomy, make it hierarchical (like categories)
        $labels = array(
            'name'              => _x( 'Categories', 'taxonomy general name' ),
            'singular_name'     => _x( 'Category', 'taxonomy singular name' ),
            'search_items'      => __( 'Search Categories' ),
            'all_items'         => __( 'All Categories' ),
            'parent_item'       => __( 'Parent Category' ),
            'parent_item_colon' => __( 'Parent Category:' ),
            'edit_item'         => __( 'Edit Category' ),
            'update_item'       => __( 'Update Category' ),
            'add_new_item'      => __( 'Add New Category' ),
            'new_item_name'     => __( 'New Category Name' ),
            'menu_name'         => __( 'Categories' ),
        );
    
        $args = array(
            'hierarchical'      => true,
            'labels'            => $labels,
            'show_ui'           => true,
            'show_admin_column' => true,
            'query_var'         => true,
            'rewrite'           => array( 'slug' => 'custompost_category' ),
        );
    
        register_taxonomy( 'super_banner_category', 'super-banner', $args );
    
        // Add new taxonomy, NOT hierarchical (like tags)
        $labels = array(
            'name'                       => _x( 'Tags', 'taxonomy general name' ),
            'singular_name'              => _x( 'Tag', 'taxonomy singular name' ),
            'search_items'               => __( 'Search Tags' ),
            'popular_items'              => __( 'Popular Tags' ),
            'all_items'                  => __( 'All Tags' ),
            'parent_item'                => null,
            'parent_item_colon'          => null,
            'edit_item'                  => __( 'Edit Tag' ),
            'update_item'                => __( 'Update Tag' ),
            'add_new_item'               => __( 'Add New Tag' ),
            'new_item_name'              => __( 'New Tag Name' ),
            'separate_items_with_commas' => __( 'Separate tags with commas' ),
            'add_or_remove_items'        => __( 'Add or remove tags' ),
            'choose_from_most_used'      => __( 'Choose from the most used tags' ),
            'not_found'                  => __( 'No tags found.' ),
            'menu_name'                  => __( 'Tags' ),
        );
    
        $args = array(
            'hierarchical'          => false,
            'labels'                => $labels,
            'show_ui'               => true,
            'show_admin_column'     => true,
            'update_count_callback' => '_update_post_term_count',
            'query_var'             => true,
            'rewrite'               => array( 'slug' => 'custompost_tags' ),
        );
    
        register_taxonomy( 'super_banner_tags', 'super-banner', $args );
    }
    
    function disableRichEdit($c) {
    
        global $post_type;
        if ('super-banner' == $post_type)
            return false;
        return $c;
    }
    
    function disableTextEditorQuickTag( $qtInit  ) {
        //Set to emtpy string, empty array or false won't work. It must be set to ","
        $qtInit['buttons'] = ',';
        return $qtInit;
    }
    
    #########custom post type end#########
    
    ?>

    Staff Note: Credentials removed for security purpose.

  • Nithin

    Hi shecom,

    I just removed 'define('DISABLE_WP_CRON', 'true');' and tried to schedule custom post but still not working.

    I checked your website, and it seems like you have disabled the default WP cron again. Also, noticed that scheduled post doesn't even work for the default Posts too, so it doesn't seem to be specific to your custom post types.

    Since I don't see you mention about performing a plugin conflict test, could you please run a quick plugin/theme conflict test as illustrated in getting support manual (flowchart), and rule out whether any plugin is causing this issue.
    http://premium.wpmudev.org/manuals/using-wpmu-dev/getting-support/

    If the plugin conflict test doesn't help much, could you please install WP Crontrol plugin, and check how the schedules work in your system, this plugin monitors the default WordPress cron tasks:
    https://wordpress.org/plugins/wp-crontrol/

    Please let us know how that goes, so that we could give a closer look. Have a nice day. :slight_smile:

    Kind Regards,
    Nithin

  • shecom

    Hi Nithin,

    My fault, "define('DISABLE_WP_CRON', 'true');" didn't remove from my code completely before, It works fine for any posts and custom posts when I completely removed the constant.

    Before I perform the suggested conflict test, I want to clarify one thing.
    Could you tell me I shouldn't use "define('DISABLE_WP_CRON', 'true');" ?
    Because I want the cronjob trigger by our server not visitors.

    Thanks

  • Nithin

    Hi shecom,

    Hope you are doing good today. :slight_smile:

    Before I perform the suggested conflict test, I want to clarify one thing. Could you tell me I shouldn't use "define('DISABLE_WP_CRON', 'true');" ? Because I want the cronjob trigger by our server not visitors.

    If you want to trigger the server cron job, then you should define the above code in your wp-config.php file. I suppose, Rupok suggested to remove the above code, just to make sure whether the issue is still present even with the default WP cron job, so that he could check whether the issue started only when you switched to your server cron job, or not.

    If the scheduled post works with the default WP cron job, then it could be the issue with how the server cron is configured, if you could enable the default WP cron job temporarily, and test these out. It would be easy to rule the out what's the issue.

    My fault, "define('DISABLE_WP_CRON', 'true');" didn't remove from my code completely before, It works fine for any posts and custom posts when I completely removed the constant.

    So when you enable the default WP cron job, the scheduled post works, except for the mentioned custom post type?

    Please let us know more about it, so that we could give a closer look.

    Kind Regards,
    Nithin

  • Nithin

    Hi shecom,

    Hope you are doing good today. :slight_smile:

    Could you please follow the instructions on setting up cron job through your Cpanel, and check whether it works:
    https://www.siteground.com/tutorials/wordpress/setup-cron-job.htm
    http://www.inmotionhosting.com/support/website/wordpress/disabling-the-wp-cronphp-in-wordpress

    Please let us know how that goes, have a nice day. :slight_smile:

    Kind Regards,
    Nithin

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.