I made a custom post_type in my wordpress site. Now trying to create a post object with special Title for each post.
Example : I want to use post title as Previous post ID +1
I tried that code :
// Create post object
$last = wp_get_recent_posts( '1');
$last_id = $last['0']['ID']+1;
$my_post = array(
'post_title' => 'Order'.$last_id,
'post_content' => 'This is my post.',
'post_status' => 'publish',
'post_author' => 1,
'post_type' => 'fp-orders'
);
But there post tile not adding +1 number. It does returning always same Title. What my wrong in the following code above?
Please give me suggestion.
THanks in advance
try this code please. You forgot to add post_type in your code.. that’s why you are not getting result.
please try my code and let me know if it works….