Tagged Questions

"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

2
votes
1answer
112 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
152 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 ...
2
votes
0answers
196 views

$wp_query meta_key naming issue [closed]

What I am attempting to do is sort posts by custom fields. I have a few custom fields that don't query properly and I get the 404 page. The fields that don't work I used hyphens in the naming ...
0
votes
1answer
690 views

how can i change WP main archives loop to sort by name or title

I've got the following code which i found somewhere else i use it for pagination. I don't understand all of it although I've read codex.wordpress.org/Class_Reference/WP_Query several times. they ...
3
votes
1answer
173 views

How to query for a week using key => value WP_Query argument notation?

I would like to be able to query for a specific year and week using WP_Query argument notation. I am using this notation as I would like the page to paginate. What's the correct "year" and "week" ...
2
votes
1answer
1k views

Page navigation doesn't show when query category

Problem: when I do www.example.com?cat=4 or choose category through custom menu or from category widget it shows only first page without navigation at the bottom, where it supposed to be. It's the ...
1
vote
1answer
146 views

Custom WP_Query with complex 'post_status' argument

I'm trying to run a WP_Query() with a bit of a twist. I need to include two post_statuses and specifically exclude another. I've got WP_Query( array( 'post_status' => array( 'publish', ...
4
votes
1answer
107 views

Tracing the life of a query

I can't find documentation regarding this - but is there a way to see how a query might bounce around from one filter to another? I've got a list of possible wp_filters and their relevance but I ...
0
votes
1answer
881 views

Custom post type, custom taxonomy, query posts only from taxonomy (children of)

I have a custom post type (portfolio-type) with a custom hierarchical taxonomy (portfolio-category) Now I would like to query only posts from potrfolio-type, so i do: $paged = 1; if ( ...
1
vote
3answers
462 views

WP_Query orderby breaks when using AJAX?

I'm running in to a bit of a problem. I have a function called get_press(), it retrieves newest press items. It is inside of a plugin: class EWPress { function __construct() { ...
0
votes
1answer
198 views

How do I get the content of a custom instance of WP_Query?

I've taken a very minimalistic loop, and tried to modify it, so that I can use more then one loop on one page. The minimalistic loop works fine and gets the content. But my modification to allow it ...
0
votes
1answer
436 views

datetime picker, timestamps and meta queries

I have a custom meta box with a datepicker. The datepicker outputs 2013-01-17 10:00 in my database for an event that is 01-17-2013 at 10pm PST. $eventlist = new WP_Query(array( 'post_type' => ...
0
votes
1answer
182 views

How can I sort posts by the date and a custom meta field?

I have custom meta field that I use for the post rating. So I want to display posts by the date and the rating, but only for the posts that have specific rating. For example, I want to display posts ...
2
votes
0answers
163 views

how do i combine keyword search and taxonomy in a WP_query $args array Worpresss [closed]

I'm trying to figure out how to get the following code to work as one wp_query . i'm trying to filter the loop on the search values and the taxonomy values: Both of these sections work independently ...
2
votes
0answers
117 views

Is it possible to orderby multiple meta_keys when using meta_value_num?

Reading through the order & orderby documentation, it's not clear to me whether there is any support to order based on multiple meta_key values. Obviously, using meta_query I can return posts ...
0
votes
1answer
138 views

Performance concerns: index.php vs taxonomy-$taxonomy.php

On one of our latest projects I'm planning to use the index.php file to display different taxonomy layouts. Basically I'm planning to use is_tax( 'sometaxonomy' ) to display the data/loop for ...
0
votes
2answers
204 views

How can i simulate “taxonomy__in” in query?

How can I have to set tax_query to get results like 'category__in' => array()? Specifically, I would like to show all the posts that have a term from the city taxonomy with one of these id's: $cities ...
3
votes
1answer
287 views

get data from wp-query, outside the loop & without url change

I am working on an advanced search on wordpress based on custom taxonomies. I've been stuck for 72h so I was hoping to have some help or thought... Step 1 --- in the js file the query strings are ...
0
votes
2answers
173 views

Creating 'posts page' loop based on the page itself

The setting Settings -> Reading -> Posts Page is set to my 'News' page, and the loop for the home.php template is populated with posts... great. However I want to also be able to create another ...
2
votes
3answers
1k views

Make First post different from rest?

Hi i'm using the code below to call post from a certain Category under certain post types, But how do i style it so that i can make the first post different from the rest of the post. <?php ...
7
votes
2answers
1k views

What is “main query”? [duplicate]

Possible Duplicate: How to know which one is the main query? I'm curious to know what is the so called "main query"? What I have is two queries on front page. if (have_posts()) : while ...
3
votes
1answer
334 views

get_query_var() not working in pre_get_posts

I'm using the pre_get_posts hook to order the main query on all my custom post type / taxonomy pages using a custom meta value. As part of the logic, I am trying to determine which taxonomy is ...
0
votes
1answer
54 views

loop and in admin header problem

I have a WP_Query loop running in a function that's attached to the 'admin_enqueue_scripts' hook add_action( 'admin_enqueue_scripts', 'rs_get_scripts'); function rs_get_scripts() { //enqueue js ...
0
votes
1answer
329 views

How to get posts published on the latest date?

Is there a way of getting all posts published on the latest date? It might not necessarily be today, it might be yesterday or the day before yesterday or even a day last week.
1
vote
2answers
525 views

pagination doesn't show up for custom post type

Another user on here suggested that my use of queries was incorrect so I'm changing the code. However, the pagination in the first block of code (below) isn't showing up in the HTML while the second ...
0
votes
1answer
338 views

Loop for custom-post-type comparing taxonomy terms for “related” posts?

I have a custom-post-type named my_projects and a custom-taxonomy called project_tags. I want to write a function that is returning 5 posts of this post-type based on a given taxonomy term. So I ...
0
votes
1answer
906 views

Get post info inside modal window?

What I'm Trying To Do I have set up a custom post type for 'movies' and below is how I set up the template. Basically, I am trying to get a.thickbox (in the code below) to open a modal window with ...
0
votes
1answer
158 views

How do i add custom post types to this query?

I'm using the code below to display the latest post from a certain category but i am using Custom Post Types and I don't know how to insert the custom post type function into this code. I want to ...
1
vote
1answer
198 views

How to know which one is the main query?

I just did an action on the query using pre_get_posts and it didn't work. When I removed the $query->is_main_query() it did work. So, how do you know that what is the main query. I know there is ...
3
votes
1answer
2k views

How can i retrieve default post per page value? from settings->reading. And total number of posts?

I want to retrieve the default value of Post per page (the value that is set in settings->reading. I've looked around and so far I've only found ways to query it. problem is i dont want to change ...
2
votes
4answers
8k views

How to get Page/Post Gallery attachment images in order they are set in backend using WP_Query()?

I am trying to retrieve all the images from the Gallery of a page in the order they are set in the backend. So far I have: $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query( ...
0
votes
1answer
189 views

Set order of returned items in the WP_Query() class/function

I have this function which gives me IDs and titles of all child pages of a given parent ID. function getPageChildren($page_id) { $my_wp_query = new WP_Query(); $all_wp_pages = ...
7
votes
1answer
6k views

Query all posts where a meta key does not exist

I am trying to get a query to retrieve all the posts where a specific meta_key does not exist and then create it. I am having problems finding those posts as the query I am testing does not seem to ...
0
votes
1answer
170 views

Is it possible to use WP Query to orderby custom meta value and custom taxonomy?

I have a custom post type with a custom taxonomy and I am trying to pull posts with a certain meta value along with a custom taxonomy (tag in my case). Is this possible and if so, how would the query ...
0
votes
1answer
351 views

Why does apply_filters behave different inside and outside a loop?

What I want: the array of posts returned by creating $query = new WP_Query($args); Why: to return specific content as a sort of API request in json format, ready to display on another site What I ...
0
votes
1answer
441 views

Wordpress SQL JOIN query

Hi Im trying to run 2 querys in the same query call. // send the query global $wpdb; $commentQ = "SELECT * FROM $wpdb->comments " . $whereClause . $orderBy; $comments = ...
0
votes
2answers
537 views

Change post query onclick

I'm trying to build kind of a filtering system for the events displayed on my website. I've made a custom post type 'Event', with a 'City' field. On my 'calendar' template page, I'm gathering all the ...
0
votes
2answers
1k views

WP Query with custom taxonomy

I'm just getting used to the WP Query and was hoping I could get some assistance on this. I've created a custom taxonomy (theme) and now want to display the latest post with one of these taxonomies ...
0
votes
1answer
219 views

How to WP Query custom multiple custom taxonomies?

I am trying to get all posts that belong to two or more taxonomies but I am failing... So here is the pseudo of what I have. taxonomy name = color-categories I have 6 created items under ...
0
votes
1answer
601 views

Default permalink structure causing Notice: Undefined property: WP_Query::$post

I use the wp for membership site. I use pages for the user log in, manage post, edit profile and etc. When I apply the default permalink structure, I found that the debug mode show this notice on ...
1
vote
2answers
122 views

Implementing an OR statement to wordpress wp_query

I am trying to return all posts that meet the following conditions: The category must be 63 OR the post must have a value associated with the meta key named 'android_link' My current argument ...
0
votes
1answer
1k views

How to insert multiple postmeta values with one query?

I have a custom script/plugin I am using for myself that creates a post along with some postmeta information. Right now, I have multiple $wpdb->insert, but I would like to condense this down into ...
1
vote
1answer
128 views

list tags with count in author profile page

I would like to list tags with count in author profile page just like this page If the user click the tag, then I would like to list the tagged posts. Can someone help me?
0
votes
1answer
75 views

WP_Query based on a custom field result

I would like to know if there's a way to do a query filtered by a custom field result. In this case, I have 6 posts I would like to retrieve, but only if they have "true" selected in a custom field ...
0
votes
2answers
697 views

What should I use, get_posts or wp_query for less CPU load?

I have a blog and on the main page are 3 blocks of posts. So, I get these posts with "get_post" and I have 3 similar codes on page: global $post; $args = array( ... ); $myposts = get_posts( $args ); ...
0
votes
2answers
2k views

How do I Use Multiple Loops with WP_Query?

Hi I am trying to add post from a certain taxonomy term to a cpt loop. The code below is the code I am using. <?php // Create empty array to store post ids in $excludes = array(); ...
0
votes
1answer
643 views

wp_query should show stickies first

I have the problem that my theme is for some reason always showing the latest posts at first. I would however like it to show all stickies at first and then show the regular ones. Here is the code: ...
1
vote
2answers
534 views

Query to return maximum of one post per author

We are introducing a "featured author" area on our site and would like to display the most recent articles by a select group of authors. However, we only want a maximum of one post per author to ...
0
votes
1answer
333 views

Using WP_Query and Query_post for the loop?

I am using the code below to call post from a certain Taxonomy term. My intentions are to mix that into the normal loop. I'm am not trying to create two different loops, but one loop that displays ...
0
votes
2answers
86 views

Do not show a custom post if it belongs to a certain custom taxonomy

I am trying to block the visualization of a custom post, of type 'product', if it is assigned to certain values of the taxonomy 'product_cat'. Strictly speaking, I would like to block the ...