I'm trying to make some plugin. This plugin is some kind of auto posting.
function new_post($title,$content)
{
$post = get_post($id);
$feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
$title = $post->post_title;
$content = $post->post_content;
echo $title;
echo $content;
}
add_action( 'publish_post', 'new_post' );
I can see only $title
, $content
is empty.
I've checked mysql in draft status, I can see post_title
fields has data but post_content
has no data.
post_content
has data when I click publish or auto save. I think this plugin run faster than wordpress insert data process.
This plugin have to run after publish or make different way.
How can I fix this code...
I hope wordpress developer's can help.
$id
coming from when looking for a post?