-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filtering a custom post type by 2 metabox fields (with 2 separate queries) #107
Comments
Definitely do incremental changes ... Also check https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters Your Are you getting output? Promo: I assume you are adding press/news/event functionality .. I've written a plugin to do what you are likely attempting to do, and events can be added with minimal effort (in fact I have an extension in the works). |
I think I've narrowed down the issue, and it involves 'posts_per_page'.
|
Update: I'm now using the following:
First loop:
Second loop:
Am I missing something as to why ASC order isn't working in the first loop? Is this a matter of needing to use |
issue resolved, this can be marked as closed |
I have a custom post type, "news", and am using two different metaboxes with it, defined in meta-setup-spec.php like this:
In news_meta.php, I've added an input group containing three radio inputs as follows:
$date_meta is using a field, sortdate, that saves dates as YYMMDD (ie, 20160518). In my page template, I have no trouble outputting posts with these args:
I'm able to display when I'm filtering on the radio input value with no problems. For example:
But I'm running into trouble when I need to run two queries at different places in my template. This is the case for posts with the radio input value of "events" - I need to display the first 4 in one part of the template, and all the rest in another. I used the following for $args:
It's also worth noting that I added another change above, which is to filter sortdate based on date values <= the current date.
For the two separate queries, I tried adding an increment, since this has worked for less complex scenarios in the past:
But no luck. Perhaps I'm trying to change too much at once...but I know everything was working fine until I, a) added the meta_query array to my $args, b) attempted to beef up my sortdate filter by only displaying current/future events, c) adding the increment. Last thing I'll mention: I also tried using two different $args and $wp_query (ie, $args1 for $wp_query1, $args2 for $wp_query2), but to no avail.
What am I doing wrong?
The text was updated successfully, but these errors were encountered: