get_posts issue
-
I am having trouble with get_posts and I have been all over the internet for 2 days and no matter what, I cannot get this working. Here is the scenario:
I have a custom post type, “Events” that has a couple of custom fields, and custom taxonomy. That all works perfectly.
Where I am running into a wall is in my template when I query that custom post using get_posts, it returns either nothing, or an incorrect dataset.
In my template, I have a “sidebar” where I want to list upcoming events, with a link to that event. I want the user to be able to narrow that list down by a category. When I leave the category out of the $args array, it returns all the posts (expected). However, if I put a category ID it breaks and returns nothing. I know there are posts in the particular category, so that’s not the issue.
Here is some code that deals with this issue:
$event_args = array( 'numberposts'=>$meta_values['right_events_display'][0], 'category'=>$meta_values['right_events_category'][0], 'post_type'=>'tf_events' ); $events = get_posts($event_args); print_r($events);exit;The above outputs:
[code moderated according to Forum Rules - please use the pastebin]
The two meta values in the
$argsarray above are values from the custom fields on the page where this will be displayed.Anyone got any ideas what I am doing wrong?
The topic ‘get_posts issue’ is closed to new replies.