"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
2answers
1k views

How to run WP_Query to retrieve attachments to posts only from a particular category?

I have a WP blog with a few pages and posts and several categories. I want to write a loop to retrieve images attached to the posts (not the pages) and only those from a specific category and it's ...
0
votes
1answer
346 views

Show multiple tax_query from 2 or more post_type in a single code

i've been trying with no success to show 2 custom taxonomies from 2 post_type, here's my code: <?php /** * Display a list of the most recent news in 'Avisos' ...
0
votes
1answer
66 views

Checking url from plugin

I'm trying to change the login url from wp-login.php to simply 'login'. I'd been looking through another plugins source to find ways of doing it. Some of the applicable parts that I've got so far: ...
2
votes
2answers
2k views

WP_Query in functions.php

I've got some code that I want to turn into a function. It works great until I wrap it in said function: $args = array( 'posts_per_page' => -1, 'post_type' => ...
0
votes
2answers
288 views

WP Query Returning All Posts

I have a custom WP query that is returning every post, instead of just the ones being specified by the query. I can't seem to find anything wrong with the code, so I must be missing something: ...
4
votes
1answer
900 views

next_posts_link not working for loop called with ajax

On my homepage I display a loop of posts that I allow to be replaced by ajax search results and other custom loops. Those results are returned in a template with a custom wp_query. The issue is ...
0
votes
2answers
858 views

Display featured posts for a custom post type by taxonomy

Ok, the quick explanation: I'm using a custom post type, 'lakes'. And, using custom taxonomies to organize them. They are: state, watertype and county. I've created a 'page' for each state that ...
0
votes
1answer
43 views

WordPress Query Returning Every Post

I have a custom WP query that searches a single custom field, using an array. The custom field is for the country of origin of a post. The array I'm using are the names of the various countries in a ...
0
votes
3answers
88 views

Creating Custom Query

I've hit some sort of stumbling bock here, and I can't find my way over it. I'm trying to craft a custom WP query that searches for posts by country of origin, selecting multiple countries at once. ...
0
votes
2answers
242 views

Parsing External Table Arguments

I have a client project that has posts assigned to their country of origin. The client wants to be able to search the posts by continent and or region. I have a separate table that assigns each ...
0
votes
1answer
187 views

Having trouble using this post category query on multiple pages?

I have three pages on my site (Listen, Read, Watch) which each query a different post category: "listen", "read", and "watch" respectively. I created three separate php files with their own unique ...
0
votes
1answer
205 views

Pagination broke after updateto Wordpress 3.4 [duplicate]

Possible Duplicate: Custom Post Type Pagination Doesn't Work in Wordpress 3.4 I updated to wordpress 3.4 and after so my pagination broke showing not found on page/2 etc. I am using ...
0
votes
1answer
333 views

wp list pages using meta box value

I am using the following meta boxes on services page but how would I get the page(s) which have value of this meta box? For example, list all pages where service_type = 'web' I am using the ...
1
vote
1answer
396 views

Sorting multiple custom post types without a meta key/value pair by sort order

At this current moment. is it possible to sort multiple custom post/page types without a meta key/value? I'm looking to just sort the posts by page attribute order: What have i done so far? I've ...
0
votes
2answers
2k views

Orderby menu_order doesn't work

My code is: $sliders = new WP_Query(array('post_type' => 'sliders', 'showposts' => '10', 'orderby' => 'menu_order', 'order' => 'ASC', 'countries'=> 'Default', 'supress_filters' => ...
1
vote
2answers
345 views

Using tax_query creates a 1 = 0 or 1 = 1 in $wp_query->request

This is my first attempt at modifying the main query using the pre_get_posts action/filter This is the function currently hooked to it: function advanced_product_search_filter($query) { ...
0
votes
1answer
2k views

Add AJAX “Load more” on custom query block

I have a index,php with various new WP_Query all working ok, but in this block I need to implement that "AJAX thing people love - the load more posts": <h2>Latests articles <?php ...
0
votes
1answer
911 views

Custom query, works, but I get a “Notice: Undefined offset: 0…”

My custom query works, but in debugging mode I get this error: Notice: Undefined offset: 0 in /storage/content/24/150624/mydomain.com/public_html/wp/mysite/wp-includes/query.php on line 2232 This ...
0
votes
1answer
262 views

Query Posts to fetch Posts with Unique Tag

I am trying to write a query post such that it returns a list fixed list of posts from a category along with any of the one tag associated with it. For eg: <?php $arg = array('cat' => ...
1
vote
1answer
150 views

recent posts for different categories

I'm developing a theme that will have two recent posts section on the home page- one section for recent portfolio updates and the other for recent blog posts. I'm struggling with implementing these ...
0
votes
1answer
2k views

Conditional arguments for WP_Query and tax_query depending on if $somevar has a value

I've created a new query for a custom post type of 'courses'. Those results are then to be filtered using tax_query, querying 3 custom taxonomies matching 1 or several term ID's. These are passed from ...
-2
votes
2answers
196 views

Query page: preserve page formating

dose anyone know how to get this query (or a different query) to preserve the page formatting? Thanks <?php $my_postid = 663;//This is page id or post id $content_post = get_post($my_postid); ...
1
vote
1answer
534 views

Compare post-IDs within WP_Query? (Less than / Greater than)

Can I use WP_Query to only query posts less than (or greater than) a given post ID? $filtered_query_args = array( 'post_type' => 'projects', 'order' => $prev_next=='next' ? 'DESC' : ...
0
votes
2answers
184 views

Custom Query Fields - Altering Meta Value

I'm giving Custom Query Fields a shot for filtering/sorting posts on the front-end of a site. The instructions seem pretty self-explanatory, but I do have another layer that I'm trying to figure out. ...
0
votes
2answers
425 views

How can I use the WordPress Loop and Pagination in multiple instances but different scenarios throughout my site?

I am using the Starker Theme as a foundation to build my custom WordPress theme. The Starker Theme comes with a loop.php file for setting up the main loop. I decided to use the loop.php file to ...
0
votes
1answer
212 views

How to display the 5 latest post titles but allow only 1 in there of a specific category

The question probably needs some clarification so here I go: I'm building a carousel displaying the titles of the 5 latest articles. However, from a specific category (called schaft in my case) it ...
0
votes
2answers
3k views

Can i merge 2 new WP_Query($variable) 's?

I am running a multisite network and i have setup a sql query that uses swith_to_blog(); and queries the posts. Is there a way that i can declare the query inside a new WP_Query and actually merge ...
0
votes
1answer
126 views

Exclude All Posts Which Do Not Have A Tag Assigned

Basically I have regular Category Listings that include posts WITH tags and posts WITHOUT tags. I need to modify the loop so that it ONLY includes posts which have one or more tags assigned to them. ...
0
votes
2answers
299 views

Disable (or limit) queries when certain content (or data) is not needed (or showed)

Currently I am making a custom design for a site. The problem I'm seeing in Wordpress is about almost all data pulled out from the database. While in certain pages - like front-page.php - it only ...
2
votes
2answers
544 views

How to order posts tag by tag?

I want to order my posts by tags with only one WP_Query() In my WP_Query I would like to display 2 posts with tags portrait 2 posts with tags paysage 2 posts with tags portrait 2 posts with tags ...
0
votes
1answer
947 views

Issue with front page navigation after upgrading to 3.4

I upgraded to WordPress 3.4 and am having an issues with showing a different amount of post on the first page versus the rest. The first page is still showing 5 posts but when I go to /page/2/ I'm ...
0
votes
1answer
473 views

Determining Author post count

This is more of an efficiency question as the following code does do what I want. $user_name = get_the_authour; $query = new WP_Query('author_name=JustinH'); $author_post_count = ...
0
votes
1answer
70 views

Change content off every sixth element

I would like to create custom post query where i will list all my posts in the list. Then the tricky bit is to add different content to sixth element off that list. So something like this ...
0
votes
1answer
173 views

get_var is neither a string, integer, or array …?

$vote_count = $wpdb->get_var($wpdb->prepare("SELECT votes FROM wp_mytable WHERE product = %s AND company = %s", $product, $company)); ...
3
votes
2answers
174 views

How to target the default Recent Posts and Recent Comments widgets with pre_get_posts?

I added the following to my functions.php: add_action('pre_get_posts', 'keyl_get_emp_posts'); function keyl_get_emp_posts($query) { if ($query->is_main_query()) ...
0
votes
1answer
216 views

Taxonomy order exception for specific term

I want to make an exception for my custom taxonomy order. Sometimes you need to put "Other" option as last option but when calling taxonomies with "orderby=name", sadly "Other" term is not listing as ...
2
votes
4answers
88 views

Get list of WP Updates Across Sites

Is there a way to query a WP site to see the number of updates currently available? I'm not really looking for a list of the actual updates, just the number. This would be the total number of ...
0
votes
1answer
866 views

How to make WP_Query not to show irrelevant posts?

I'm using the following WP_Query arguments array: $args = array( 'post_type' => POST_TYPE, 'tax_query' => array( 'taxonomy' => ...
0
votes
1answer
2k views

Posts limit on homepage (genesis framework)

in home.php // NOT working query_posts('show_posts=3'); // NOT working add_action( 'pre_get_posts', 'set_posts_per_page' ); function set_posts_per_page( $query ) { $query->set( ...
1
vote
2answers
2k views

How do I use wp_query for WordPress search?

I would like to create a custom search form to search posts based on the values of about 4 custom fields. I tried using wp_query to achieve this but so far my biggest problem is that the I don't get ...
0
votes
3answers
2k views

Query with pre_get_posts to get pagination

After pretty much getting everything working with query_posts, I noticed my pagination wasn't running. I was told pre_get_posts should be the solution. My problems: I don't know how to pass all my ...
0
votes
2answers
837 views

How to filter a static post page with ajax and $wp_query

I'm at a loss, I've found several unanswered questions related to this one. I have a static post page which has a search form in the sidebar. What I want to happen is to type in a keyword and then ...
0
votes
1answer
875 views

How to Loop within a Loop (Display Children and then Grandchildren)

I am trying to develop a query for WordPress that will allow me to display a list of child pages with titles only, and then under each child page title, a list of grandchilden (children of the child) ...
0
votes
1answer
2k views

Multiple post type queries (with specific arguments for each)

So i know how to combine post types into 1 loop and out put the loop. Below is what i have: <?php $args = array( 'post_type' => array('post','movie','actor'), ...
5
votes
2answers
766 views

WP_Query leaking absurd amounts of memory

Every time I call WP_Query() in the function below, Wordpress leaks 8 megs of memory. And since I call this function a lot, things get hairy pretty quickly... :( I've tried unsetting the resulting ...
0
votes
1answer
386 views

Alter secondary loop to exclude posts from current page category

The below code is taken from sidebar.php where it outputs random posts from multiple categories and excludes the current post from showing up. This works great but how do I alter this loop to exclude ...
0
votes
2answers
246 views

Problem with wordpress pagination

First of all thank you everyone for all the knowledge base i got reading trough stackexchange. For the first time i couldn't find an answer to my problem. The matter is that with this custom query ...
0
votes
1answer
3k views

Limiting the number of posts in WP_Query leads to unexpected result

The following is supposed to display 10 posts. Sometimes it displays 11, sometimes 12, and sometimes the desired 10 posts. It behaves the same if I swap posts_per_page for showposts or numberposts . ...
1
vote
3answers
1k views

how does $wpdb differ to WP_Query?

I'm going to write a function to return the next/prev post in a specific category. can anyone tell me what the differences would be in using $wpdb as opposed to WP_Query(); eg new WP_Query(args)? what ...
11
votes
3answers
472 views

What is appropriate flow for custom data from URL in WP_Query?

I have multiple stage process that integrates complex faceting into WP queries. Problem is - the deeper I get the more fuzzy I become on how it is supposed to work and I could use a guideline rather ...