Closed. This question is off-topic. It is not currently accepting answers.admin管理员组文章数量:1315231
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 4 years ago.
Improve this questionI have some seasonal products. I thought using "post expirator plugin" but this not managing the "yearly" options. So I thought doing something like this:
function saison(){
$current_month = date('M');
if( $current_month == 'Dec' || $current_month == 'Jan' ) {
wp_update_post( array(
'ID' => 789,
'post_status' => 'publish'
));
} else {
wp_update_post( array(
'ID' => 789,
'post_status' => 'draft'
));
}
}
Someone know how to make something like this in my function.php ?
Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 4 years ago.
Improve this questionI have some seasonal products. I thought using "post expirator plugin" but this not managing the "yearly" options. So I thought doing something like this:
function saison(){
$current_month = date('M');
if( $current_month == 'Dec' || $current_month == 'Jan' ) {
wp_update_post( array(
'ID' => 789,
'post_status' => 'publish'
));
} else {
wp_update_post( array(
'ID' => 789,
'post_status' => 'draft'
));
}
}
Someone know how to make something like this in my function.php ?
Share Improve this question edited Aug 11, 2018 at 12:11 Lust asked Aug 11, 2018 at 10:34 LustLust 411 silver badge7 bronze badges1 Answer
Reset to default 0date('M') => 'Aug' and date('m') => 08
add_action('wp', function(){
$current_month = date('M');
if( $current_month == 'Aug' ) {
wp_update_post( array(
'ID' => "product_id",
'post_status' => 'publish'
));
} else {
wp_update_post( array(
'ID' => "product_id",
'post_status' => 'draft'
));
}
});
本文标签: post statuschange woocommerce product statut (draft gtpublishpublishgtdraft) depends on the month
版权声明:本文标题:post status - change woocommerce product statut (draft ->publishpublish->draft) depends on the month 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741981238a2408408.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论