Hello,
I need to utilize the <strong>post date</strong> as title of my post in a custom post type. I am using:
function status_title_filter( $cleanPost )
{
if( $cleanPost['post_type'] == 'cpt-daily-specials' && $cleanPost['post_status'] != 'auto-draft' && $_GET['action'] != 'trash' && $_GET['action'] != 'untrash' )
$cleanPost['post_title'] = $cleanPost['post_name'] = $cleanPost['post_date'];
return $cleanPost;
}
add_filter( 'wp_insert_post_data', 'status_title_filter' );
and it works great, except I <strong>don’t want the time</strong>. This method above is best solution so far because it utilizes to posts scheduled date verse todays date.
The time is causing issues with permalinks, I am soo close!
<em>Any assistance you can provide would be much appreciated!</em>
Source: http://wordpress.stackexchange.com/questions/15800/set-custom-post-type-title-to-the-posts-date
Dbranes answers:
You could try:
function status_title_filter( $cleanPost )
{
if( $cleanPost['post_type'] == 'cpt-daily-specials' && $cleanPost['post_status'] != 'auto-draft' && $_GET['action'] != 'trash' && $_GET['action'] != 'untrash' )
{
$cleanPost['post_title'] = $cleanPost['post_name'] = date_i18n( 'Y-m-d', strtotime( $cleanPost['post_date'] ) );
}
return $cleanPost;
}
add_filter( 'wp_insert_post_data', 'status_title_filter' );
West Coast Design Co. comments:
Perfect, I LOVE YOU!
West Coast Design Co. comments:
It works, did this site change, how do I close the question and reward you? lol
Dbranes comments:
ok great to hear it's working for you,
ps: you can check out the link under your question : <em>Tutorial: How to assign prize money</em>
cheers