"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

4
votes
1answer
87 views

How do you get the count of posts in an archive page?

I have a custom posts archive page of the type archive-my_custom_post_type.php and I am using the "standard" loop which consists of the ever-so famous <?php if(have_posts()) : ?> <?php ...
0
votes
1answer
99 views

Display count number of posts with the same specific meta_key meta_value

I want to display a list of posts ordered by a specific meta_key. My posts have the following custom fields: author_lastname and author_firstname. So far, it works good. The posts are displayed ...
2
votes
1answer
116 views

How to make a WP_Query search with custom post types?

I've registered a custom post type called "node". When I create a basic WP_Query to get posts of that type, it works just fine. Example: $args = array( 'post_status' => 'publish', 'post_type' ...
1
vote
1answer
38 views

How to ensure “the_content” filter runs only for the main displayed content?

I have a plugin which adds the method to "the_content" filter. add_filter('the_content', 'myFilteringFunction', 10000); Within that function I want to add some links on the beginning and the end of ...
-1
votes
1answer
142 views

How to query posts from specific authors and categories using WP_query?

I currently have a WP_query where I am getting posts from a specific set of authors. To this, I want to add specific categories as well. $args = array( 'author__in' => $authors, 'posts_per_page' ...
0
votes
0answers
26 views

Archive by months with pretty url?

I wanted to able to get the archive months working, I tried this http://codex.wordpress.org/Function_Reference/wp_get_archives#Last_Twelve_Months but it only gets the last 12 months, what I wanted ...
0
votes
2answers
66 views

Highlight current post title on a page

In my menu I have a page that is called Campaign. When the user enters to Campaign the page displays the last custom post type of campaign-post. In the sidebar of Campaign page, I'm displaying a ...
0
votes
1answer
59 views

Wordpress Numeric Pagination with Query String [duplicate]

So I have a dynamic loop which is affected by a query sting in the URL.. For example I have 3 categories and when they click the category it just adds a query to the URL: <a ...
0
votes
0answers
28 views

Problem accessing values from $wp_query in plugin

I am creating a custom plugin where I am passing parameters in the url and trying to access the values of those parameters using $wp_query directly in the plugin, but it returns an empty array. I ...
0
votes
0answers
77 views

wp_update_post not working

I have the following code in a single script to be run one time to fix post names which are empty. // WP_Query arguments $args = array ( 'post_type' => 'books', ...
0
votes
3answers
28 views

Query Vars Not Set in Main Query

I have a function that checks page specific and global settings to determine a class related to sidebars. I call the function from the archive.php template and try to check that post_type is 'post', ...
0
votes
0answers
49 views

Query posts filter not working

I have created one custom post type which name is villa. In this post type I have added five post and assigned custom field values(mention bellow): Post Name Assigned Fields 1. Chalet ...
0
votes
0answers
16 views

WP_Query For Custom Author and Single CPT Search?

I have created a search page where users can search the site with these options: (1) Keyword (2) Keyword in/from 12 different Custom Post Types (CPT's) (3) Keyword in/by a single Author's posts ...
0
votes
1answer
37 views

Are term_taxonomy_id and term_id the same?

I have a custom query where I need a JOIN because I want to COUNT all the posts of a specific category. So I checked the tables and I found out that table wp_term_relationships contains a reference ...
0
votes
1answer
13 views

When filtering query on custom taxonomy; main menu dissapears

I have created a custom taxonomy, and that works. But here is the problem; I have created an archive page, which in the url gets e.g. this: ?category=23. Then, in functions.php, I do this: function ...
1
vote
1answer
44 views

No content found on page 2 of pagination with 1 post per page

This loop (used on a taxonomy-term archive page) is not paginating correctly. The older/newer links for page 2 are there, but when I click on older, it returns "no content found" (when what I expected ...
0
votes
0answers
15 views

Customize Query to include a custom parameter

I have a link on a page, which goes to a loop using information from a meta field on that page. I'm a bit confused by this, but I'm trying to learn because this seems quite powerful. As I ...
0
votes
0answers
16 views

Serve different layout via URL parameter

I'd like to be able to serve up an alternative layout for single posts via an URL parameter. For example, a user going to: http://domain.com/postname/ will get the post in the normal layout and a ...
0
votes
0answers
40 views

Displaying Single Future Posts in a specific Category or Taxonomy

I want posts that are tagged with a certain term and scheduled to be posted some time in the future to be publicly available. So if I create a post, assign it a special term (category, tag, custom ...
0
votes
1answer
41 views

The next_posts_link() show me a aditional page in blank

The description Hi, I am using a custom post type and a loop through the values ​​I show. I'm using a term ($ term) that comes from a previous page in the loop to only show related items. Just for ...
0
votes
2answers
55 views

Get posts after calculating meta key

I have 2 meta fields for the posts, eg. meta_value and meta_count. Both are numbers. I want to divide meta_value by meta_count and based on the results I want to fetch the top 10 posts. So for ...
0
votes
1answer
30 views

Why won't draft listings appear for non-admins?

I have a draft post with the author set to 5. User #5 is trying to view that draft on the front end using a WP_Query with the following arguments: array { ["name"]=> "example-52f00a8ba19f4" ...
2
votes
2answers
81 views

How can i get the last post from wp multisite?

I have to get the last post from my Multisite network on WordPress. For now I use this code for display the last updated post after a cycle on each blog_id: <?php $blogs = get_last_updated(' ', ...
1
vote
1answer
47 views

Query custom post type in the loop

I have a custom post type running called services: // Services function services_cpt() { $labels = array( 'name' => _x( 'Services', 'post type general name' ), ...
0
votes
1answer
11 views

allow previews outside wordpress folder (Outsourcing WP previews)

I am outsourcing the wordpress and I already figured out the external view. I even know how to make a WP query for previews, but when I want to do that I simply cant - wp-load stops all operations and ...
0
votes
0answers
13 views

Wp query for custom template page [duplicate]

I want to create custom page template, which this custom page I am copy it from index.php. On index.php I have 3 columns ( 2 sidebar and 1 list content column). But on this custom page I plan to ...
0
votes
1answer
60 views

Posts in loop all show the same author when there are many authors

I am iterating through an array of post IDs $ids. All is displayed correctly except for the authors. Every post shows the same author, although the posts are by different authors. I can't seem to get ...
0
votes
2answers
38 views

Creating two loops based on different logic

I'm trying to figure out the best way to go about this and I have part of my solution, but I can't figure out all of it. My ultimate goal is within a certain page template, to show the newest post ...
0
votes
0answers
19 views

query two meta values [duplicate]

hey guys a few days ago i asked my question but i didnt getting it work. simple question. i got this in my theme: $querystr = " SELECT $wpdb->posts.* FROM $wpdb->posts, ...
0
votes
0answers
68 views

AJAX Pagination not working

I have integrated an AJAX Pagination in my site sidebar, where I'm showing custom post type. Here is my code: <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $new_query = ...
0
votes
2answers
92 views

WP_Query get posts where post_name is empty

I want to get all the posts for which the post_name(slug) is not set/empty as well as a meta_key does not exist. $args = array ( 'post_type' => 'books', 'name' ...
0
votes
3answers
150 views

How to get posts from two categories with WP_Query?

I'm using WP_Query to create 'latest posts' & 'popular posts' sections on my home page. I'm trying to just pull 5 posts from 2 categories (9 & 11) but it will only show posts from cat 9. ...
0
votes
1answer
28 views

using nav menu id's

I am trying to make a WP_Query that gets all pages / posts from the navigation id. I have the id's. I have a variable that holds the numbers and when I echo it out, this is exactly what I get ...
0
votes
1answer
83 views

meta_query on a date range using an array of values

How can I do a query to return the post if the custom field array contains a date that is within the specified range? The query below is basically what I am after but it does not work... // the ...
0
votes
1answer
14 views

meta_query dates from an array

I have the below query which isn't returning anything. The query is meant to look for the date (2014-03-01) that is in the array, which it is. Any ideas? Or would I need to use a custom SQL query? ...
0
votes
0answers
46 views

Second foreach loop breaking (Posts2Posts)

I've read about a couple of similar issues that Google gave me (1 & 2), but I can't quite get to the bottom of this problem. Using Posts 2 Posts, I'm building a table of posts and their related ...
0
votes
0answers
54 views

How to get duplicate array count with custom post type

After printing array I am getting output like this: Array ( [0] => WP_Post Object ( [ID] => 8 [post_author] => 1 [post_date] => 2014-01-31 ...
0
votes
2answers
211 views

Query multiple meta key values for template

I am using this template: http://demo.undsgn.com/studiofolio/front-page/ I tried to make some modifications because I need the homepage template to display an excerpt beneath each thumbnail. I copied ...
0
votes
0answers
58 views

Custom post type pagination, single page issue

After having problems getting pagination working at all for custom post types, I've read that the custom post type name and the page name cannot be the same. So I set out from scratch: I've created ...
0
votes
2answers
54 views

WP_Query of Category Not Showing First Post

I have the following loop, and only this loop, in my home.php file (apologies if I didn't paste the code properly). I have populated lorem ipsum posts, and noticed that of the five posts only four ...
0
votes
1answer
48 views

What's the purpose / logic of split_the_query in WP_Query->get_posts

In the get_posts method of WP_Query, there's a section relating to split_the_query The logic of split_the_query is $split_the_query = ( $old_request == $this->request && ...
0
votes
0answers
63 views

Using WP_Query IN pre_get_posts while searching

This is a continuation on this question. What I'm trying to do, is rerun a search query, to loop through it and index the taxonomy counts (so I can make some kind of facet search). What I do is this ...
1
vote
1answer
36 views

WPDB query - decrypting DB data

I am trying to grab data from the DB using WPDB but I am stuck on how to decrypt the data e.g. The data is stored as: a:2:{i:0;s:2:"92";i:1;s:2:"71";} I want the 92 & 71 as that's my post IDs, ...
0
votes
1answer
278 views

How to get posts in different language from WPML Plugin

i'm using Thermal-Api plugin in order to define a REST WS to get posts in JSON format. My Client uses WPML to translate posts and i need to pass to WP_Query the language set in front-end side. Is ...
0
votes
2answers
55 views

Remove category from query (show all posts in archive.php) pre_get_posts()

I am using pre_get_posts() to allow all posts to be displayed on any category archive. This is because I will provide a javascript sorting and filtering method using isotope.js. Any category page will ...
0
votes
0answers
20 views

Query Posts oder by Date

my query does not work as it should. This is my Code: wp_reset_query(); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'post_type' => 'post', ...
4
votes
1answer
22 views

WP query taxonomy input differs to output?

I'm trying to build a custom query and I need to include the current category ID. I previously had the WP_Query args as: Array ( [post_status] => publish [posts_per_page] => -1 ...
0
votes
0answers
12 views

WP query taxonomies not the same as output

I'm trying to build a custom query and I need to include the current category ID. I previously had the WP_Query args as: Array ( [post_status] => publish [posts_per_page] => -1 ...
0
votes
1answer
39 views

Get posts by list of post IDs ordered by those IDs?

I am going to make a "favourite" posts box, but the article id's are stored in another DB so I only get an array of IDs (which are relevant to the WP DB). I think it could be done with get_posts() or ...
1
vote
1answer
22 views

Custom Query - show first post twice?

In a custom query, is there a way to show the first post twice? I want to show the first post in a certain format at the top of my query, then again right under it along with my other posts (maybe a ...