在WordPress支持的新闻门户网站中,他们需要在一天中的某个时段,在大多数情况下,在晚上10点之后(今天)上传许多新闻。但他们实际上是在插入第二天(明天)的新闻。所以以WordPress的方式,他们需要在每次发布时安排新闻(帖子)。
相同的重复作业-编辑时间,将日期更改为即将到来的日期(即19),将小时更改为12,将分钟更改为01。这很费时,也有点令人不安。
有没有一种方法我可以为他们做一件普通的事情,这样他们就可以设置一次并将所有帖子上传到新设置的时间?可以随时重置计时吗?
在WordPress支持的新闻门户网站中,他们需要在一天中的某个时段,在大多数情况下,在晚上10点之后(今天)上传许多新闻。但他们实际上是在插入第二天(明天)的新闻。所以以WordPress的方式,他们需要在每次发布时安排新闻(帖子)。
相同的重复作业-编辑时间,将日期更改为即将到来的日期(即19),将小时更改为12,将分钟更改为01。这很费时,也有点令人不安。
有没有一种方法我可以为他们做一件普通的事情,这样他们就可以设置一次并将所有帖子上传到新设置的时间?可以随时重置计时吗?
这里有一个sketch 另一个想法,我们在那里创造scheduling shortcuts 为方便用户,请执行以下操作:
我们可以使用post_submitbox_misc_actions
要向提交框添加额外字段,请执行以下操作:
/**
* Scheduling-Shortcuts fields.
*
* @see http://wordpress.stackexchange.com/a/168748/26350
*/
add_action( \'post_submitbox_misc_actions\', function() {
if( ! current_user_can( \'publish_posts\' ) )
return;
?>
<div style="padding: 2px 10px;">
<h4><?php _e( \'Scheduling shortcuts:\' ); ?></h4>
<ul class="schedule-shortcuts">
<li>
<input type="radio" value="current"
name="wpse_schedule_shortcut"
id="shcedule-shortcut-0" checked="checked" />
<label for="shcedule-shortcut-0"><?php _e( \'Current settings\' );?></label>
</li>
<li>
<input type="radio" value="tomorrow_at_12"
name="wpse_schedule_shortcut" id="shcedule-shortcut-1" />
<label for="shcedule-shortcut-1"><?php _e( \'Tomorrow @12\' );?></label>
</li>
</ul>
<?php wp_nonce_field( \'schedule_shortcut_action\',\'schedule_shortcut_field\'); ?>
</div>
<?php
});
然后,我们可以通过wp_insert_post_data
过滤器:/**
* Scheduling-Shortcuts post data handling.
*
* @see http://wordpress.stackexchange.com/a/168748/26350
*/
add_filter( \'wp_insert_post_data\', function( $data, $postarr ) {
if( defined( \'DOING_AUTOSAVE\' ) && DOING_AUTOSAVE )
return $data;
if( ! current_user_can( \'publish_posts\' ) )
return $data;
if( ! isset( $postarr[\'post_type\'] ) || \'post\' !== $postarr[\'post_type\'] )
return $data;
if( ! isset( $postarr[\'action\'] ) || \'editpost\' !== $postarr[\'action\'] )
return $data;
if ( ! isset( $postarr[\'schedule_shortcut_field\'] )
|| !wp_verify_nonce($postarr[\'schedule_shortcut_field\'],\'schedule_shortcut_action\')
)
return $data;
if( isset( $postarr[\'wpse_schedule_shortcut\'] )
&& \'tomorrow_at_12\' === $postarr[\'wpse_schedule_shortcut\']
)
{
$data[\'post_status\'] = \'future\';
$data[\'post_date\'] = date( \'Y-m-d H:i:s\', strtotime( "+1 day 00:00" ) );
$data[\'post_date_gmt\'] = gmdate( \'Y-m-d H:i:s\', strtotime( "+1 day 00:00" ) );
}
return $data;
}, 10, 2 );
希望您可以根据自己的需要进一步调整。好的,我的一位非WP同事Shamim先生提出了一个临时解决方案。并在WP 4.0中测试成功&mdash;It\'s the bulk publish from drafts.
我们的想法是,无论发布什么系列的帖子或一堆帖子,首先将它们保存为草稿。然后,在时间上,当时间到了时,将所有这些项都检查一组,从Bulk Actions
下拉菜单,然后在展开的面板上,从状态中选择“已发布”,最后点击Update.
但它有一个缺点,当你想发布所有的帖子时,你必须回到帖子列表。
我有自定义帖子(实际上是页面),可以在默认页面(page home.php)上查看,但如何创建一个单独的页面,包含完全相同的内容,并链接到它?主页。php(默认WP页)代码当前为:<?php /* Template Name: Home News */ ?> <?php get_header(); ?> <div id=\"content\"> <div id=\"inner-cont