"wp-query" ambiguously refers to one of two things. 1) WP_Query is a class native to Wordpress which allows users to query the posts database using a number of criteria. 2) $wp_query is the default object that holds the main query object on each WordPress page.

learn more… | top users | synonyms

0
votes
1answer
1k views

Category 'pad_counts' & 'parent' conflict

Below is the current loop I have setup: <?php //start products category loop $args = array( 'hide_empty' => 0, 'parent' => 0, ...
0
votes
2answers
236 views

Get all custom_post_type posts + blog posts from one category in a single query

Is there a way to query posts from multiple post_type's and filter the normal blog posts by a category? I am trying to display the 10 latest custom_post_type posts and blog posts on my homepage in a ...
0
votes
1answer
1k views

Is it possible to create a shortcode that will query a post based on taxonomies?

I am working on a site that will be listing a few hundred products and we wanted to be able to quickly/easily show specific products on a page based on taxonomies. I have been doing some research and ...
2
votes
1answer
1k views

wp_query custom post type by taxonomy & standard post by taxonomy

Anyone know how I can neatly combine a query to pull CPT by a custom taxonomy and also standard posts by taxonomy into same query to list all posts together on my home page? for example: $args = ...
2
votes
1answer
479 views

SQL Query inside Widget

I have a widget which contains the following code: <? global $wpdb; $querystr = "SELECT name FROM wp_venues WHERE name ='".the_field('venue')."' "; $info = $wpdb->get_var($querystr); echo ...
0
votes
1answer
766 views

Custom WP Query from meta_value stored as serialised array

I'm using a Magic Fields 2 multicheck box to store Services which can be assigned to Case Studies. The data is stored as a serialised array in WordPress, and I need some help to extract the "related ...
2
votes
1answer
6k views

Multiple WP_Query loops with Pagination

There are a few other questions about this (and WP_Query pagination seems to be a huge question for a lot of people) so I'm trying to narrow down exactly how to make it function. I'm able to create a ...
0
votes
1answer
60 views

Date not appearing in custom query

I'm having a weird issue with Wordpress which I cannot solve by myself, and for which I couldn't find an aswer over this and other websites. Basically, I have a custom loop. while ( ...
1
vote
1answer
503 views

WP_Query filter and order by meta ordering by wrong joined table

I'm trying to both filter and order a Wordpress query using the meta_value, however the ORDER BY part of the query seems to be working on the wrong table. The query params here are: array(12) { ...
-1
votes
1answer
342 views

How to write short code with if else to get page_id?

<div class="group-training"> <?php while ( $page_loop->have_posts() ) : $page_loop->the_post(); ?> <div class="entry"> <h1><?php the_title(); ...
0
votes
1answer
62 views

How to query for posts with either one or another custom field

Need help querying for posts with either one or another custom field. Not sure how to use the 'or' operator here, but something like this the blow - Have tried these: ...
1
vote
4answers
2k views

Loop through all tags & output posts in alphabetical list

I have a bunch of posts that each have multiple tags, and I'm trying to find a way to output all of them on a single page, organized under an alphabetical listing of their respective tags. E.g. if ...
1
vote
1answer
2k views

pagination not working for category.php (custom post types in categories)

it works everywhere on my site but it isnt working in category.php. When i click page to it goes to... domain.com/category/cat-slug/page/2 by the way this is showing custom post types within certain ...
0
votes
1answer
1k views

CSS class on last post in loop ( custom query )

I have been using this question to try to do this but I am having some difficutlty. I have a custom post type, media, and I am working on the archive-media.php template. I have it partially working ...
0
votes
2answers
398 views

Custom taxonomy in WP_Query not working

I'm truly stumped here. I have a specific taxonomy for sorting posts into different types of "featured" posts on a news site. Here's the problem: When querying by them the results aren't what they ...
0
votes
1answer
468 views

How to fetch only media that was already attached to a post/page?

Situation: my client has this simple gallery built with WP_Query showing the latest media added to the site: $cola = new WP_Query( array( 'post_type' => 'attachment', 'post_status' ...
0
votes
2answers
3k views

WP_Query multiple use of relation and/or

I have 2 custom fields that I would like to do a meta query on for a custom post type: start_date status The outcome that I am looking for is (start_date >= 1332115200 AND status = 1) OR ...
0
votes
2answers
3k views

Custom post type - filter content by custom meta box content

I have custom post type with some products. I need to add some content filtering now. I have custom meta box with "author". I want to add buttons with authors that will act like categories. So let me ...
1
vote
1answer
725 views

how do i remove posts from a WP_Query so the pagination is right?

I'm using a custom post type and showing 20 of them per page on the homepage. I'm using QP_Query. One custom field for the custom post type (called mixtapes) is a checkbox called "unreleased" (set ...
1
vote
2answers
680 views

How to display a posts 1 year ago with custom WP_Query loop?

I have a custom WP_Query loop that I use for the main archive page. How can I filter the custom query to diplay posts from within 2 days +/- of one year ago from todays date? My current query: ...
0
votes
1answer
227 views

Pagination not working

$paged for pagination is awlays returning 1, so no matter what page i click "1" is always highlighted and it always shows the same posts. i have tried a million different combinations of things to fix ...
0
votes
1answer
224 views

Trying to output content from page, works locally but not online

I am using the following code, to output the content from a page with the id of two. This is in my custom template file which is selected in the page. It works fine locally but online it does not ...
0
votes
1answer
676 views

How to Check if a Child Category is Being Queried

I need to change the number of posts queried for specific categories 'Recipes' or 'Product Reviews'. The below code works great for this, I have it in functions.php: function ...
0
votes
1answer
577 views

Multiple Custom Field Query

I have a unique situation where I need to filter on 2 custom fields where 1st field is expiry and values of "" and greater than todays date are valid and 2 field is a number which should be greater ...
6
votes
1answer
4k views

How do I check if a post has a post thumbnail in WP_Query?

I want to grab the 5 most recent posts that have thumbnails.
0
votes
1answer
77 views

Add category to my get_post query

I am using this Query to pull in the latest 3 post <?php $query = 'posts_per_page=3'; $queryObject = new WP_Query($query); // The Loop... if ($queryObject->have_posts()) { while ...
0
votes
1answer
285 views

Custom Post Type Query issue

I have a conflict issue with 2 custom post types. I have a template file archive-media.php and have created the related 'media' custom post type. This all works well, however in the sidebar I have a ...
0
votes
1answer
1k views

Ajax (jquery) wp_query pagination returns -1

I am currently developing an ajaxified theme for wordpress. I am listing the posts in a particular category, but the pagination returns -1 when clicked. Lets say I set showposts to 3 and a particular ...
0
votes
1answer
52 views

Adjust query on single

I am building an event manager. One of the template files I have is events-single.php which displays single events. At the bottom of this I have next and previous events using next_post_link and ...
1
vote
2answers
360 views

Counter problem, infinite loop when post_per_page equals X

(updated) I´m using this query to loop divs in to my front page slider. I use counters to split 4 posts into a slider, then open a new slider etc. Also a counter to set a class to every fourth post ...
2
votes
1answer
1k views

Pagination for custom query on single.php

I'm building a site and the basic structure on most pages is as follows: <!-- content query --> <!-- recent posts preview query (paginated) --> <!-- related posts preview query ...
0
votes
1answer
496 views

Get_the_term_list inexplicably adds values in foreach

I'm trying to get three values from all my custom posts, to populate a Google Map with the places where I've been. All is going fairly well, except for an issue I'm having with get_the_term_list. For ...
0
votes
1answer
1k views

cannot override post_types in WP_Query()

I'm creating a featured post slider which takes 4 pages or posts from the 'featured' category. I'm trying to use WP_Query, but am having no joy :( my slider query is: $ml_featured = new WP_Query( ...
0
votes
4answers
469 views

Why always one post missing

In my custom query, every time I query for posts from a particular category using WP_Query() and the category has 10 posts for example, I seem to be missing a post. So querying for 10 posts only ...
0
votes
3answers
1k views

Single parent post lists child posts with pagination

I would like to build on this answer so I can incorporate pagination and a couple of other features. We have over 1,600 entries in our Glossary so certain letters have far more than 20 (my max ...
0
votes
1answer
1k views

How do I list a custom field and custom taxonomies for each result in a loop?

How do I list a custom field and custom taxonomies for each result in my loop below? <?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); ...
0
votes
1answer
519 views

Compare meta_query decimals not working right

I have a custom field named 'rating' that holds decimals from 1.0 to 10. I am trying use wp_query to get me all the posts with a rating of 8.0 to 10. What I have so far almost works perfectly but it ...
2
votes
2answers
6k views

Why is “/page/2/” not working?

Finally got pagination to work with the below code, but now the pagination links to /videos/page/2/, which doesn't exist. How do I get page 2 to work? <?php $temp = $wp_query; $wp_query= null; ...
1
vote
3answers
2k views

Using new WP_Query in shortcode in a custom field causes the main post content to not display

I've got a custom post type of files I'm trying to list using a new WP_Query. It works fine when I add the shortcode within the main post content. However, when I add the shortcode to a custom field ...
0
votes
1answer
68 views

How do I query posts and have their related taxonomies returned in the results?

I have created a custom post type that contains television channel data. Each channel has its own post. I have also created a custom taxonomy of channel groups. What I want to do is query all the data ...
6
votes
2answers
2k views

How to set a custom post type to have viewable future posts

I've setup a CPT to act the same ways as posts but used to post event details. Thing is that some of the posts are in the future and such have a future date set on them. Problem is that normal users ...
1
vote
1answer
3k views

How to grab metabox value in wp_query meta_query key

How would I modify my WP_Query in order to get a custom meta box value instead of a custom field one like I currently do? This is how my query looks like: <?php $today = ...
0
votes
2answers
386 views

Second wp_query doesn't appear to be working

I've set up this query in Wordpress to find all associated news for a company: <h2 class="heading">Related News</h2> <?php $link = get_the_title(); ?> <?php ...
1
vote
1answer
1k views

Show only oldest post by author

I am working with a heavily customized install of WP. I've set up a specific post type, taxonomy, and roles that gets to use just that post type. Ideally, I'd like to restrict members of that role ...
1
vote
1answer
7k views

WP Query to get all posts (including in draft/pending review)

I currently have the following query: $args = array( 'post_type' => 'post', 'orderby' => 'title', 'order' => 'ASC', ...
0
votes
1answer
203 views

the_post(); prints out style text into my HTML?

Every time I use the_post(); in my theme code, the following is echo'ed into my pages: <style type="text/css"> <!-- .formTitle { font-size:20px; font-weight:bold; ...
1
vote
1answer
297 views

Sorting By Custom Posts With Attachments

I think I've got this figured out and I'd like to make sure I'm not missing anything obvious. My goal is to prioritize a list of results by custom posts with attachments. So, I have a query returning ...
1
vote
5answers
12k views

Get all categories and posts in those categories

I am looking for a solution that allows me to print the following: Cat 1 Cat 2 Cat 3 Post 1 Post 1 Post 1 Post 2 Post 2 Post 2 Post 3 Post ...
0
votes
2answers
689 views

Wordpress posts for multiple years

Trying to get posts from a specific category for specific years. Nothing is working, including this: <?php $args=array( 'cat' => '11', //Category I'm targeting 'year' => 2008,2009,2010 ...
0
votes
1answer
798 views

Wordpress query by multiple Custom fields and order by date

So here is my query: $args = array( 'post_type' => 'Event', 'posts_per_page' => 1000, 'meta_key' => 'event_informations_show_on_the_homepage', 'meta_value' => 'Show on ...