$post_title not being saved during wp_insert_post (1 post)

  1. pszeinert
    Posted 4 years ago #

    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:

    do_action ('save_title');
    	function save_title() {
    		if (isset($post_ID)) {
    			$this_post = $post_ID;
    		} else {
    			$this_post = "";
    		global $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);
    		$custom_title = array();
    		$custom_title['ID'] = $this_post;
    		$custom_title['post_title'] = $my_post_title;
    		$custom_title['post_content'] = 'This is a custom post of the sport_event type. If you can see this text, something is wrong';
    		$custom_title['post_name'] = $my_post_name;
    		// Insert the post into the database
    		wp_insert_post ( $custom_title );

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.