admin管理员组文章数量:1326316
This might be a long post but I want to explain in detail what I'm trying to do and what I've already done.
I'm making custom forms using the advanced custom fields plugin and I need to display these custom forms in a calendar. So I'm using the plugin WP fullcalendar for that, it works but instead, it displays on the posts published date not the date I chose w the date and time picker.
In the support forums for the plugin, I followed this / but to no avail and instead everything is blank on the calendar for me.
So I thought maybe I could change the publication date of the post so that it can display at the correct time. I found this code here / (you need to scroll towards the bottom to get to the code)
And I need only a certain post types pub date to be changed. Please know that I am a novice at PHP and had to learn it very recently on the spot so I'm not confident at all in what I've done or how to implement the code. (I added the code to the functions.php file)
if( get_post_type() == 'cpost2' ) {
add_action('acf/save_post', 'change_pub_date', 20);
function change_pub_date($post_id) {
// remove this filter to prevent potential infinite loop
remove_filter('acf/save_post', 'change_pub_date', 20);
// date format must be "Y-m-d H:i:s"
$post_date = get_field('post_date');
$post = wp_update_post(array(
'ID' => $post_id,
'post_date' => $post_date));
}
} else {
return false;
}
From add action to the post_date bit is the code from the second link, but it doesn't change anything.
Any help would be very much appreciated!!
本文标签: custom post typesChanging wordpress publication date to ACF date and time picker date not working
版权声明:本文标题:custom post types - Changing wordpress publication date to ACF date and time picker date not working 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742204451a2432555.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论