I have a front end form that let users submit a post.
This is how i store the data when a post is submitted :
if ( isset( $_POST['submitted'] )) {
$post_information = array(
'post_title' => wp_strip_all_tags( $_POST['postTitle'] ),
'post_content' => $_POST['postContent'],
'post_type' => 'post',
'post_status' => 'publish'
);
$new_post = wp_insert_post( $post_information );
The post is not showing in my post page unless i go through my dashboard and click over The UPDATE button.
THIS IS HOW I QUERY MY POSTS :
$args = array(
'posts_per_page' => 5,
'paged' => $paged,
'meta_query' => array(
array( 'key' => '_wti_like_count','value' => 5, 'compare' => '<=','type' => 'numeric')
)
);
query_posts( $args );
How can i make my submitted posts publish automatically?
The post gets added and published but since you have the meta query and the meta key is not added when you submit the post from frontend, it does not show up. Use the following code which adds the meta data as needed.
I am not sure but i think that is because of you didn’t added the author into the
$post_information
: