I am submitting a custom post type post from front end wordpress with pending status. I am trying to retrieve the pending post in the front end but it was not showing. I checked the same in admin portal, the pending post is showing there. 1. Able to post the custom post type with pending status using the below code. 2. Not able to show the pending post in front end but it was showing in admin portal pending posts. 3. If i post new post or save post as pending in admin portal and that post was showing in front end pending post listing. 4. The below code was working in local server but not working in client server.
Even i have checked the wordpress database, Trying one pending post from front end and admin portal, "posts" table showing the same entry columns. I am unable to find the difference in the database.
// Below code for inserting the post with pending status
$post = array(
'post_title' => $_POST['event-name'],
'post_content' => $_POST['event-description'],
'post_date_gmt' => date("Y-m-d h:i:sa"),
'post_status' => array('pending'),
'post_type' => 'events',
'meta_input' => array(
'custom_name' => $_POST['your-name'],
'custom_phone' => $_POST['your-phone'],
'custom_email' => $_POST['your-email']
)
);
// Below code for retrieving the pending post
$args = array(
'post_type' => 'events',
'post_status' => array('pending'),
'post_per_page' => 10,
'order' => 'desc'
);
I checked through the wp_debug true, it was not throwing any type of errors. Expected output, front end page should show the pending post.
If any one have idea how to proceed this further, I am struck with this.
posts_per_page
notpost_per_page
2)wp_debug_display
must also be defined astrue
to show errors. Neither of these would stop there query working though. Have you correctly defined the events post_type? – andrew