wordpress计划数据库条目

时间:2016-07-05 21:49:49

标签: wordpress

我是wordpress的新手想知道它存储日程数据的位置。我在帖子中看到的而不是已发布的数据状态显示未来和正在发布的那个时间和状态从未来变为已发布。我直接在数据库中将少数帖子的状态更改为future,并将post_date和post_date_gmt的时间更改为将来的时间,但未公布,状态与未来保持一致。 我认为wordpress将数据存储在其他一些表中的其他地方,并根据该表触发cron。任何帮助都会很棒

wp_options中的cron vlaues是

a:8:
{i:1467778980;
a:1:{s:19:"nxs_querypost_event";
a:1:{s:32:"40cd750bba9870f18aada2478b24840a";
a:3:{s:8:"schedule";s:11:"nxsreposter";s:4:"args";
a:0:{}s:8:"interval";i:90;}}}i:1467781670;
a:1:{s:16:"nxs_hourly_event";
a:1:{s:32:"40cd750bba9870f18aada2478b24840a";
a:3:{s:8:"schedule";s:6:"hourly";s:4:"args";
a:0:{}s:8:"interval";i:3600;}}}i:1467781924;
a:1:{s:24:"akismet_scheduled_delete";
a:1:{s:32:"40cd750bba9870f18aada2478b24840a";
a:3:{s:8:"schedule";s:5:"daily";s:4:"args";
a:0:{}s:8:"interval";i:86400;}}}i:1467787812;
a:3:{s:16:"wp_version_check";
a:1:{s:32:"40cd750bba9870f18aada2478b24840a";
a:3:{s:8:"schedule";s:10:"twicedaily";s:4:"args";
a:0:{}s:8:"interval";i:43200;}}s:17:"wp_update_plugins";
a:1:{s:32:"40cd750bba9870f18aada2478b24840a";
a:3:{s:8:"schedule";s:10:"twicedaily";s:4:"args";
a:0:{}s:8:"interval";i:43200;}}s:16:"wp_update_themes";
a:1:{s:32:"40cd750bba9870f18aada2478b24840a";
a:3:{s:8:"schedule";s:10:"twicedaily";s:4:"args";
a:0:{}s:8:"interval";i:43200;}}}i:1467791880;
a:1:{s:20:"wp_maybe_auto_update";
a:1:{s:32:"40cd750bba9870f18aada2478b24840a";
a:3:{s:8:"schedule";s:10:"twicedaily";s:4:"args";
a:0:{}s:8:"interval";i:43200;}}}i:1467817919;
a:1:{s:19:"wp_scheduled_delete";
a:1:{s:32:"40cd750bba9870f18aada2478b24840a";
a:3:{s:8:"schedule";s:5:"daily";s:4:"args";
a:0:{}s:8:"interval";i:86400;}}}i:1467820230;
a:1:{s:30:"wp_scheduled_auto_draft_delete";
a:1:{s:32:"40cd750bba9870f18aada2478b24840a";
a:3:{s:8:"schedule";s:5:"daily";s:4:"args";
a:0:{}s:8:"interval";i:86400;}}}s:7:"version";i:2;}

2 个答案:

答案 0 :(得分:0)

TL; DR 值在wp_options表中,其中option_name ='cron'。

使用WordPress cron将帖子从未来移到发布,你是对的。当您安排发布以供将来发布时,WordPress会默认更新选项表中的“cron”条目(wp_options,但如果您更改了表前缀,则会有所不同。)

adds a publish_future_post entry到存储的数组(使用wp_schedule_single_event()函数)。

实际发布是通过check_and_publish_future_post()功能完成的。

该值是PHP序列化的,因此使用数据库查询进行更新可能会非常棘手。

修改

继我的评论之后,这些是我在该表中看到的之前(没有未来的帖子)和之后(一个未来的帖子)值。

在:

'a:4:{i:1467810391;a:3:{s:16:\"wp_version_check\";a:1:{s:32:\"40cd750bba9870f18aada2478b24840a\";a:3:{s:8:\"schedule\";s:10:\"twicedaily\";s:4:\"args\";a:0:{}s:8:\"interval\";i:43200;}}s:17:\"wp_update_plugins\";a:1:{s:32:\"40cd750bba9870f18aada2478b24840a\";a:3:{s:8:\"schedule\";s:10:\"twicedaily\";s:4:\"args\";a:0:{}s:8:\"interval\";i:43200;}}s:16:\"wp_update_themes\";a:1:{s:32:\"40cd750bba9870f18aada2478b24840a\";a:3:{s:8:\"schedule\";s:10:\"twicedaily\";s:4:\"args\";a:0:{}s:8:\"interval\";i:43200;}}}i:1467853602;a:1:{s:19:\"wp_scheduled_delete\";a:1:{s:32:\"40cd750bba9870f18aada2478b24840a\";a:3:{s:8:\"schedule\";s:5:\"daily\";s:4:\"args\";a:0:{}s:8:\"interval\";i:86400;}}}i:1467855934;a:1:{s:30:\"wp_scheduled_auto_draft_delete\";a:1:{s:32:\"40cd750bba9870f18aada2478b24840a\";a:3:{s:8:\"schedule\";s:5:\"daily\";s:4:\"args\";a:0:{}s:8:\"interval\";i:86400;}}}s:7:\"version\";i:2;}','yes');'

后:

'a:5:{i:1467802230;a:1:{s:19:\"publish_future_post\";a:1:{s:32:\"c235acd81e1457babc4e93303796723c\";a:2:{s:8:\"schedule\";b:0;s:4:\"args\";a:1:{i:0;i:20;}}}}i:1467810391;a:3:{s:16:\"wp_version_check\";a:1:{s:32:\"40cd750bba9870f18aada2478b24840a\";a:3:{s:8:\"schedule\";s:10:\"twicedaily\";s:4:\"args\";a:0:{}s:8:\"interval\";i:43200;}}s:17:\"wp_update_plugins\";a:1:{s:32:\"40cd750bba9870f18aada2478b24840a\";a:3:{s:8:\"schedule\";s:10:\"twicedaily\";s:4:\"args\";a:0:{}s:8:\"interval\";i:43200;}}s:16:\"wp_update_themes\";a:1:{s:32:\"40cd750bba9870f18aada2478b24840a\";a:3:{s:8:\"schedule\";s:10:\"twicedaily\";s:4:\"args\";a:0:{}s:8:\"interval\";i:43200;}}}i:1467853602;a:1:{s:19:\"wp_scheduled_delete\";a:1:{s:32:\"40cd750bba9870f18aada2478b24840a\";a:3:{s:8:\"schedule\";s:5:\"daily\";s:4:\"args\";a:0:{}s:8:\"interval\";i:86400;}}}i:1467855934;a:1:{s:30:\"wp_scheduled_auto_draft_delete\";a:1:{s:32:\"40cd750bba9870f18aada2478b24840a\";a:3:{s:8:\"schedule\";s:5:\"daily\";s:4:\"args\";a:0:{}s:8:\"interval\";i:86400;}}}s:7:\"version\";i:2;}'

区别在于publish_future_post条目:

i:1467802230;a:1:{s:19:\"publish_future_post\";a:1:{s:32:\"c235acd81e1457babc4e93303796723c\";a:2:{s:8:\"schedule\";b:0;s:4:\"args\";a:1:{i:0;i:20;}}}}

答案 1 :(得分:0)

只需将此代码添加到主题的functions.php文件

即可
function wpb_upcoming_posts() { 
        // The query to fetch future posts
        $the_query = new WP_Query(array( 
            'post_status' => 'future',
            'posts_per_page' => 3,
            'orderby' => 'date',
            'order' => 'ASC'
        ));

    // The loop to display posts
    if ( $the_query->have_posts() ) {
        echo '<ul>';
        while ( $the_query->have_posts() ) {
            $the_query->the_post();
            $output .= '<li>' . get_the_title() .' ('.  get_the_time('d-M-Y') . ')</li>';
        }
        echo '</ul>';

    } else {
        // Show this when no future posts are found
        $output .= '<p>No posts planned yet.</p>';
    }

    // Reset post data
    wp_reset_postdata();

    // Return output

    return $output; 
    } 
    // Add shortcode
    add_shortcode('upcoming_posts', 'wpb_upcoming_posts'); 
    // Enable shortcode execution inside text widgets
    add_filter('widget_text', 'do_shortcode');

短代码:

<?php echo do_shortcode('[upcoming_posts]');?>

[upcoming_posts] 

希望如此工作