Trying to save post_title in custom post
-
Just noticed the thread about the sub-forum so I will resubmit.
I have posted two other threads related to this issue, but sadly it seems to be over the head of some of the best minds on here since I have had zero replies.
My current method is as follows:
add_action ('wp_insert_post','save_title',99,2); function save_title($post_ID, $post) { global $post; if (isset($postid)) { $this_post = $postid; } else { $this_post = ""; } $custom = get_post_custom($this_post); $event_team = $custom["event_team"][0]; $event_opponent = $custom["event_opponent"][0]; $event_date = $custom["event_date"][0]; $my_post_title = ($event_team ." vs. " .$event_opponent ." - " .$event_date); $my_post_name = sanitize_title($event_team ."-vs-" .$event_opponent ."-" .$event_date); $post = array( 'ID' => $this_post, //Are you updating an existing post? 'post_content' => 'This is a custom post of the sport_event type. If you can see this text, something is wrong', //The full text of the post. 'post_name' => $my_post_name, // The name (slug) for your postet the status of the new post. 'post_title' => $my_post_title ); // Insert the post into the database return $post; }
My previous attempts at automatically writing the post_title are located here and here.
Help would be much appreciated. I am having to hand type the titles for this season, but I would like to make this user friendly for next year.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Trying to save post_title in custom post’ is closed to new replies.