admin管理员组文章数量:1130349
i try to build a form that users posts from frontend,
everything works fine but i need to know if it's possible,
if i play with the 'post_date' => date('Y-m-d H:i:s')?
if i add a hidden field that generates the expiration day (+30 days from the post day) and then add it to the post with add_post_meta($post_id, 'expiration', $expDate, true);
anyone have any ideas how i can build something like this?
thanks a lot,
Philip
i try to build a form that users posts from frontend,
everything works fine but i need to know if it's possible,
if i play with the 'post_date' => date('Y-m-d H:i:s')?
if i add a hidden field that generates the expiration day (+30 days from the post day) and then add it to the post with add_post_meta($post_id, 'expiration', $expDate, true);
anyone have any ideas how i can build something like this?
thanks a lot,
Philip
2 Answers
Reset to default 3The post by itself is only data, it cannot perform such action as expiring itself. So you need some form of external control to act on it.
You can use WP Cron (see wp_schedule_event() and related) to run periodic task that will query for posts by your custom field and perform wanted action on them (trashing, cancelling published status, etc).
Some plugins handle this as well such as my Post Expiration Date, which does not require WP Cron. WP Cron is fine if you have it, but not everyone does and not all hosts support it.
i try to build a form that users posts from frontend,
everything works fine but i need to know if it's possible,
if i play with the 'post_date' => date('Y-m-d H:i:s')?
if i add a hidden field that generates the expiration day (+30 days from the post day) and then add it to the post with add_post_meta($post_id, 'expiration', $expDate, true);
anyone have any ideas how i can build something like this?
thanks a lot,
Philip
i try to build a form that users posts from frontend,
everything works fine but i need to know if it's possible,
if i play with the 'post_date' => date('Y-m-d H:i:s')?
if i add a hidden field that generates the expiration day (+30 days from the post day) and then add it to the post with add_post_meta($post_id, 'expiration', $expDate, true);
anyone have any ideas how i can build something like this?
thanks a lot,
Philip
2 Answers
Reset to default 3The post by itself is only data, it cannot perform such action as expiring itself. So you need some form of external control to act on it.
You can use WP Cron (see wp_schedule_event() and related) to run periodic task that will query for posts by your custom field and perform wanted action on them (trashing, cancelling published status, etc).
Some plugins handle this as well such as my Post Expiration Date, which does not require WP Cron. WP Cron is fine if you have it, but not everyone does and not all hosts support it.
本文标签: theme developmentSet Expiration Date of a Post from the Frontend with wpinsertpost
版权声明:本文标题:theme development - Set Expiration Date of a Post from the Frontend with wp_insert_post 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749225923a2335611.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论