"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.
0
votes
1answer
408 views
List all custom post type posts from a given category?
I have a custom post type myposttype and it's taxonomy is called myposttype_categories.
myposttype_categories have multiple terms inside, such as foo and bar.
The tricky question is - how do I list ...
0
votes
2answers
188 views
Recent Posts slider, using WP_Query(), loads duplicate sliders
I have written a small piece of code for Wordpress that will show the most recent top 4 posts in a slider (the Filament Group Responsive Carousel). It works, displaying the posts and sliding them etc, ...
1
vote
0answers
46 views
Keep sticky posts out of query unless they have featured image
I have a query running which prevents posts without various criteria from appearing, one of these is the necessity to have a featured image. Sticky posts however seem to end up in the query ...
0
votes
2answers
199 views
Setting get_queried_object
I know that get_queried_object contains the object that was queried for the current page. My question is, what methods of querying affect the contents of this?
For instance:
query_posts
get_posts
...
0
votes
1answer
139 views
Make WP_Query more efficient?
Ok - so using a WP_Query to count votes by a user. But now there are 23,000 votes and its using up lots of memory.
Is there a way i can make this WP_Query more efficient?
$args = array(
...
0
votes
1answer
131 views
WP_Query pulling an extra post per page
I'm querying to get a list of all posts, 20 posts_per_page, but the result shows all posts, but with 21 posts per page. If I change posts_per_page to 19, then 20 show. One post is sticky and shows up ...
0
votes
1answer
70 views
Cannot query custom post type taxonomy from theme options array
I am having no luck with querying a custom post type taxonomy from an array in theme options.
My full code is below, would be grateful for some feedback to get it working correctly as I cannot get ...
1
vote
1answer
133 views
How to display 7 most recent days of posts?
I would like to be able to display on my homepage a timeline of posts from 7 of the most recent days. For example, if today is January 1, 2013, I would like my blog feed to display something that ...
0
votes
1answer
92 views
Custom page template query_vars
I created a custom page template movie-page.php and a page movie in WP. The template shows fine when I visit site.com/movie/
I want to add movie_id as a query var. Here's my code:
...
0
votes
1answer
100 views
Wordpress search exact match
I have a few search filters set up and I found a few posts that shouldn't be in the search results. On looking into it further I found these posts match 'part' of the keyword.
For example, searching ...
0
votes
1answer
46 views
Query by post title
I've used a custom post type for one of my website. Custom post type contains scratch card data along with some custom fields.
I've developed an android application to manage those items from android ...
0
votes
3answers
119 views
Listing all custom post types using a specific term on the said term's template page, in groups
I have a custom tag-like taxonomy called PEOPLE registered to all post types - both the default and custom ones.
I have created a template for a single term named taxonomy-people.php and I'm ...
0
votes
1answer
210 views
Why WP_Query('showposts=5') shows only 1 post?
I am trying to do a simple query to get the latest 5 posts into an unordered list, but this is only showing 1 result even though I have several posts. I even did an offset, but it shows the next post ...
0
votes
1answer
71 views
WP_Query posts by distance based on LAT & LNG in Database
I've got table in the WordPress database that has lat & lng stored and I'd like to add a sort feature on the results page 'Sort by Distance' that gets the locations that are closer to your ...
-1
votes
1answer
39 views
why do drafts return as part of wp_query?
I have some code as plugin, which I call via AJAX from a page one the site. It gets two drop-down values and uses them in tax_query to fetch some posts. Question: why do drafts return amongst results ...
1
vote
1answer
65 views
WP_Query Variable inside Array
The array below with "'taxonomy' => 'age'" isn't working, if I copy and paste the array "array( '19', '20' )" in place of the variable it works fine. I just started picking up PHP so go easy on me :)
...
0
votes
2answers
75 views
exclude a post from wp_query loop
0 down vote favorite
I show my last post in a page with this code:
$query1 = new WP_Query();
$query1->the_post();
and it further with:
$id = $query->ID;
to retrieve last post ID so I ...
0
votes
1answer
78 views
filter the_content, custom post type, and wp_query
I thought this was going to be quick and easy, but naturally it's turning out to be more complicated. I'm writing a simple plugin that creates a custom post type "Ad", and then puts a random ad at ...
0
votes
1answer
24 views
Reordering content using a meta value
I've got this theme where you can add posts of type "portfolio", and I want to be able to reorder them up. I've added a custom meta field called "position" and I've set already those values. All good. ...
1
vote
1answer
67 views
Best Practice For Querying Grandchildren?
Objective: Query and loop through a page's third-level "grandchildren" in a way that allows pagination.
Here's the code that I'm using (pagination excluded):
// Get the ID of the first ...
0
votes
1answer
63 views
Pagination 404 errors for author posts query on author.php
I'm trying to query all posts by an author and paginate them on the author.php page. I've tried messing with the WP default blogs per page settings and that doesn't help. I've looked at other posts ...
3
votes
1answer
680 views
Custom Taxonomy and Tax_Query
I've been having a lot of trouble getting a WP_Query running with a tax_query on my custom taxonomy.
I'm 99.9% sure that my register_taxonomy is correct, as I'm able to tag posts with the right term, ...
0
votes
2answers
107 views
Multiple Categories under one URL, where 'Front Page' is used already
I couldn't find an answer relating to this, maybe I just didn't come across it yet.
So the setup of the site I am working on at the moment:
The Front Page is not set, is default. I can't change this ...
1
vote
1answer
82 views
Use WP_Query with have_posts()?
Is it possible to use
$items = new WP_Query( $query_args );
with
<?php if(have_posts()): ?>
<?php while (have_posts()) : the_post(); ?>
without changing the loop to be
<?php ...
0
votes
1answer
51 views
Loop being strainge
So I hacked together a function that does the following:
protected function _query_post($query){
$original = $this->_wp_query;
$wp_query = new WP_Query($query);
...
1
vote
1answer
41 views
Query Posts With Over 1000 Views
The code below is from this link. It basically creates a hit counter, but I'm probably gonna have to do this by IP.
How do I make a WP_Query, where only posts up to 1000 views can be seen on the ...
0
votes
2answers
74 views
Pagination problem after WP_Query with tag filtering
I have a problem with a custom WP_Query. I want a page with all posts with a specific tag. This is the code I'm using:
<?php
//save old query
$temp = $wp_query;
//clear $wp_query;
$wp_query= ...
2
votes
1answer
311 views
WP Query group/order by category name
I have a requirement for displaying a list of custom post types grouped by category, but in addition to this, each custom post is linked with a meta value (in this example lets say we have a custom ...
0
votes
0answers
24 views
All posts not being displayed [closed]
I have built a site that uses the "posts" type to display their galleries as normal posts. It is set to be sorted by custa meta date and continue on down the page.
As of right now, I have made 15 ...
2
votes
1answer
247 views
Advanced Custom Fields query
I have, hopefully easy question. I have my query here, which is using ACF
<?php query_posts(array('post_type' => 'our-clients-list', 'posts_per_page' => 1, 'order' => 'DSC', 'orderby' ...
2
votes
0answers
39 views
Query meta field using between
I'm trying to Query some lattitude and logitude and then I get some long numbers and apperently the Query dont like that.
Let says I have these in the database
Meta-key: lat
Meta-value: 54.3415000
...
-1
votes
1answer
48 views
Trying to WP_Query a category
I am trying to output all the posts of a certain category but all that is happening is The page content is being outputted no posts?
template page
<?php
/*
Template Name: Blog
*/
?>
<?php ...
0
votes
4answers
247 views
WP_Query and using a variable for 'cat'=> in the args array = WP Bug?
For the sake of this discussion, here's a version of my query within category.php:
wp_reset_query();
$category_id = get_cat_ID(single_cat_title('', false));
$my_query = new WP_Query(array(
...
0
votes
1answer
56 views
Using Query In Post Type Archives
I'm using the script below to call post from a certain category in the sidebar. It pulls from all post type on the homepage and on the single post page, but when it comes down to the post type archive ...
2
votes
1answer
223 views
Using is_main_query to select custom post type on certain page
I've been trying to implement some of the ideas discussed by Andrew Nacin http://wordpress.tv/2012/06/15/andrew-nacin-wp_query/ into my workflow, specifically trying to move away from using ...
0
votes
1answer
67 views
Display 3 posts with different HTML markup using a loop
I want to be able to display 3 posts from the same category on my index.php page, but due to the way my site's HTML/CSS is coded I'm having some difficulty understanding the correct way to go about ...
0
votes
1answer
91 views
WP Query - duplicated posts once including tags in search results
I running WordPress on IIS & SQL server. As some of the plugins do not work correctly with DB ABSTRACTION I am using a lot of functions.php filters as so on.
To make my search results include ...
1
vote
2answers
104 views
Given a WP_Query, how can I get a list of tags?
I have a new WP_Query that I use to generate a custom loop and display a set of posts. One of the things the query does is provide pagination.
Before I display the queried posts though, I'd like to ...
2
votes
2answers
125 views
Why Does get_posts() Return an Empty Set?
I'm writing a custom plugin that is initialized at init. This plugin is trying to query for some custom post types already stored in the DB.
Here's my code:
$args = array()
$myposts = get_posts( ...
0
votes
0answers
52 views
Complicated Custom Post Type Query drill down, using meta query
I currently have defined a few custom post types.
a product category size
a product category
a product.
Inside my product, I hold and save meta data on a dropdown list of product categories. So ...
1
vote
1answer
36 views
How to combine custom fields to make one order-able value
I have three different custom fields, for day (01-07) hour (01-12) and minute (00-59) and I really need to combine them into one custom value so I can actually order them using wp_query.
I cant ...
0
votes
1answer
106 views
Search.php - return number of results but cannot loop through
I have a following search.php page (this is just the code required for problem presentation).
Why is my $total_results returning a number of posts found, but when I do a loop though it always print ...
0
votes
1answer
82 views
Tax_Query using WP_Query not working
I cannot get this query to work properly. It just renders one post even though I have three posts that are categories in the 'Firm News' and 'Test' categories.
Can anyone see a problem with my code?
...
0
votes
1answer
116 views
How can i list random post from multiple category?
I have an author page, and I want to list posts from current author's categories.
e.g. I'm viewing John's page, and John wrote in Sport, Tech, News, Computer categories.
Then my code list from this ...
0
votes
2answers
122 views
Custom-Posttype & Custom Taxonomy WP_Query
I add a custom post type with custom taxonomy and i wish to get all postings into this by a template, but the result is 0
$args=array(
'post_type' => 'contents',
'post_status' => 'publish',
...
1
vote
1answer
87 views
Recommended way to drop a pending query (in pre_get_posts)?
It looks like an e-commerce plugin's core query will be of no use to me in one particular template so I would like to discard it completely in favor of my own WP_Query loops in the template. It's not ...
1
vote
0answers
72 views
Query custom post types and a specific page?
I'm using this query WP_Query('post_type=product&posts_per_page=8') I need to include a specific page into the query but not sure how to add it since I'm only specifying the custom post type? Is ...
1
vote
1answer
89 views
Using OR in WP_Query negates the “NOT EXISTS” compare
I'm attempting to filter posts by a custom field that either are equal to 'new' or have not been set yet. I'm able to get either of those meta_queries to work on their own but when I use them in an ...
2
votes
0answers
40 views
When querying a combination of posts and other meta fields, is there a better solution than directly modifying the WHERE value?
This question is a follow up to a question I recently asked.
I've implemented what seemed to be the only solution, and it seems to work (YAY!). I just need to verify that:
This is really the only ...
3
votes
1answer
87 views
Search widget breaks when using multiple loops?
I have created wordpress template that uses two loops via WP_Query object. Everything works fine except Search widget. I've been pulling my hairs out for three days now Googling like a madman,but ...


