Home › Forums › Calendar Products › Events Calendar PRO › Querying Pending/ Draft Events
- This topic has 3 replies, 2 voices, and was last updated 9 years, 1 month ago by George.
-
AuthorPosts
-
April 6, 2015 at 4:14 pm #953586colinParticipant
When events are created via community events they are created with a draft status however when i query an event by it’s post id it will not appear in the query even if i set the status. do you have a solution for this. on event_tribe function which returns event data for a give post id regardless of status
$event_id = 1001;
$args = array(
‘p’ => $event_id,
‘numberposts’ => -1,
‘post_type’ => ‘tribe_events’,
‘post_status’ => array(‘draft’,)
);
$query = new WP_Query();
$posts = $query->query( $args );April 7, 2015 at 4:54 am #953664GeorgeParticipantHey Colin,
Thanks for reaching out here. First, if you already have the Event ID, then does the simpler function get_post() work for you? Like this:
$post = get_post( 1001 );
That example assumes that 1001 is your post ID. You can learn more about the get_post() function here → https://codex.wordpress.org/Function_Reference/get_post
If you’re only querying for one event post, I really recommend just using get_post() instead of WP_Query.
If you want to use WP_Query instead, then one thing I noticed about the code you posted here was a typo for the ‘post_status’ parameter. In the code you posted, it looked like this:
‘post_status’ => array(‘draft’,)
That extra comma after the word ‘draft’ could be causing problems, so make sure it’s just this:
'post_status' => array( 'draft' )
Let us know if any of this information helps!
Cheers,
GeorgeApril 7, 2015 at 6:04 am #953674colinParticipantget_post($event_id) does the trick thanks
April 9, 2015 at 9:48 am #954371GeorgeParticipantNice! Best of luck with your project Colin, cheers.
-
AuthorPosts
- The topic ‘Querying Pending/ Draft Events’ is closed to new replies.