开发者 | |
---|---|
更新时间 | 2024年12月13日 17:21 |
PHP版本: | 7.2 及以上 |
WordPress版本: | 6.7 |
版权: | GPLv3 or later |
版权网址: | 版权信息 |
private
.
/wp-content/plugins/taro-clockwork-post
directory, or install the plugin through the WordPress plugins screen directly.Setting > Reading
and choose post type to expiration ready.Private is the default post status but if you want another case, use filter hook for that.
// Filter status if post type is `product`
add_filter( 'tscp_expired_status', function( $status, $post ) {
if ( 'product' == $post->post_type ) {
$status = 'no-stock';
}
return $status;
}, 10, 2 );
If status is false
, this plugin doesn't change post status.
In such situation, you might need adding any custom field to post.
Use another action which will occur just after tscp_expired_status
.
// do something just after post status is/isn't changed.
add_action( 'tscp_post_expired', function( $post ) {
// Post is still publish,
// But add some custom fields
update_post_meta( $post->ID, '_not_in_front_page', true );
} );
If you are low-resource environment, you might need low frequency. For example, assume that your site allows posts to be expired within 10 min. Use hook to delay interval. add_filter( 'tscp_cron_interval', function() { // Change interval from 60 sec to 600 sec. return 600; } );
show_ui = true
.withState
from editor script.