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

0
votes
1answer
76 views

New WP_query in template not working with CPT+category on some pages

I have three page templates, homepage, documentary, and corporate, each using the same CPT WP_query code with only the category name changed for each respectively. The homepage works fine, pulling and ...
0
votes
2answers
36 views

WP order ASC in custom author loop

My current author list shows authors with posts only, but its not ordered by ASC and its not working. Any ideas? <ul class="authorlist"> <?php // displays all users with their avatar and ...
1
vote
1answer
102 views

How to get the posts published in last two days using WP_Query?

I am trying to loop through all the post to get the top most shared posts on social network. I want to use the date_query parameter in the WP_query to get the posts of last two days , last 5 days, ...
0
votes
1answer
50 views

WP_Query by Category Name

Hi I am using some code to display posts in a slider on a page, and at the top I have some code to filter it using WP_Query. Here it is, not sure what is wrong: <?php /** * Featured Content 2 * ...
0
votes
0answers
46 views

WP_QUERY loop, offset in the arguments and the paginate_links - can these work together?

I have a page where the first 4 posts from category 7 are displayed with their own query and style. Then I have a small box were I want to display the rest of the posts from category 7 and to use a ...
0
votes
0answers
28 views

Show different number of posts per page in tag archives

I am using the following code out of loop to show one post per page in tag archive. <?php query_posts($query_string."&showposts=1") ?> However, I want to show recent posts as 10 posts ...
0
votes
1answer
27 views

Where is the WP_Query instance instantiated (when working with themes)?

This may be a very basic question, but I could not find the answer. The following documentation http://codex.wordpress.org/Class_Reference/WP_Query shows the code // The Query $the_query = new ...
0
votes
1answer
27 views

Can't use orderby in WP_Query

I can't get my posts to order by the date, descading. I've got the following code: $jobs = new WP_Query(array( 'posts_per_page' => 50, 'post_type' => 'job', 'post_status' => ...
0
votes
0answers
294 views

Problem with WordPress 4.0 and $wp_query

On my website I have a logo area that is controlled by a function that determines which page the user is on and loads the specific content depending on the $page_id value. Since WordPress 4.0 there ...
0
votes
0answers
11 views

Pagination on author page

I created a custom query inside author.php, and I would like to add pagination. The problem is that the result is 404 error everytime. $args = array( 'post_type' => 'wpost', 'author' => ...
1
vote
2answers
107 views

WP Query orderby meta key natural sort?

I have this code: $args = array( 'posts_per_page' => -1, 'post_type' => 'product', 'meta_key' => 'custom key', 'orderby' => 'meta_value', 'order' => ...
0
votes
0answers
31 views

Complicated WP_Query

I'd like to query wp posts in custom way, I'm not sure whether or not WP_Query class can do this, but I'd like order the posts by posts that has a specific custom taxonomy and then continue with the ...
0
votes
0answers
32 views

How to show custom post type in page hierarchy?

Is it possible to show a list of pages with a custom post type included in that list if it's parent is a page? So if I was using the query more specifically something like get_pages(), ...
0
votes
1answer
37 views

Query outputting YouTube url rather than embedded video

I am having an issue with a query outputting the YouTube url rather than the video itself. The post I am querying has a Youtube url in the content area. Of course, when viewing the post, you don’t see ...
0
votes
0answers
58 views

Why does order ASC break offset in WP_Query?

I have a function being used in an AJAX call for adding the next 5 posts. The call checks the amount of posts being displayed already and send that as an $offset parameter. The $args for query_posts ...
1
vote
1answer
55 views

Future post ID not showing

I'm attempting to send an email notification when a scheduled post is published. I've tried quite a few different ways. I receive the email but the id (and other random details) are not published with ...
1
vote
2answers
78 views

How to display future posts - modified query still yields 404

I have a very strange problem and I am stuck. I want the single page to display posts with the post_status of publish and future. So I added this code to my functions.php in my theme: function ...
0
votes
0answers
19 views

Is it possible to apply a meta_query to one specific post type in a query with multilple post types?

I have two post types, news and events : A news has no custom fields. An event has two custom fields : start-date and end-date. I want to display news and events on the same page, ideally with ...
0
votes
3answers
42 views

How to get all author posts outside of author templates

Currently, I'm trying to display all posts from an author(e.x admin) in a custom page with name that is completely different than these template file listed here. So inside this page, I'm using WP ...
1
vote
1answer
195 views

Pagination on a WP_query not showing navigation links

I'm having trouble adding pagination to a page. I'm using WP_query and would like to pull back 4 posts per page. The basic query seems to work OK but I must be missing something regarding pagination. ...
-1
votes
1answer
27 views

Query for page content, and query for posts on the same page?

I'm having trouble with trying to make a blog listing page, I have a page in Wordpress called Blog. Within this is some written content and that's it. I'm using the following query to make it output ...
0
votes
1answer
50 views

Custom Post Type meta oembed html output resulting in WSoD

For a homepage template I'm trying to query a custom post type with a couple custom meta boxes. They are a title, oembed text field, and text area. I've compiled the below code from various sources as ...
0
votes
1answer
54 views

new WP_query using custom fields

I am trying to query child posts from two parents (that part is working fine), ... but now I want to exclude posts that have a meta_key of 'feature' with a meta_value of '1' Using the Codex ...
0
votes
0answers
42 views

jQuery Ajax decompose WP_Query

I am working on a Ajax search field where I want to load links to products matching with my search query. My problem is that I don't know how I can get the titles and the permalinks from the query ...
1
vote
1answer
56 views

How to set multiple `orderby` in query argument?

I am trying to fetch pages by multiple ordering. menu_order in descending and title in ascending. Following is the argument: $args = array( 'post_type' => 'page', 'posts_per_page' => 20, ...
0
votes
0answers
41 views

running queries of multiple post types

I am trying to figure out the query I need to build for my project. I've got a little idea but i am getting confused by all the different query methods and I'm not sure which one to use. I have two ...
1
vote
1answer
26 views

WP Query Exclude and Start by Menu Order Offset

I have a set of posts in a custom post type that I have given menu order attributes to. I am hoping to use wp_query to query the first 3 by menu order, then the next 3 by menu order. For example - ...
0
votes
1answer
40 views

How to retrieve the date on which a post was moved to trash?

I need to retrieve a list of posts that are in trash based on the date on which they were trashed. The following code allows me to retrieve posts that are in trash, but how to filter them by date? ...
2
votes
1answer
50 views

WP-Admin edit.php & post.php slowdown after import of 10k users

Situation: Clean wordpress install No plugins VPS server 5.2ghz / 4gb RAM (Default Directadmin) Import of 10k users Problem: WP-Admin edit.php and post.php take >4sec to load. A custom post ...
0
votes
1answer
34 views

How to overwrite orderby with add_query_var

So I would like to have an archive that displays its posts in a random order. <?php $query = new WP_Query($query_string."&orderby=rand"); ?> But also then if the user chooses they ...
0
votes
1answer
61 views

Why does “get_option” pull in the older value in options.php, rather than the newer value, on submission of a form?

I'm building a simple post order "plugin" through my theme's functions.php. The function updates the value of an option in options.php on submission of a form. So, for instance, when "1" is inputted ...
0
votes
2answers
34 views

Having Trouble Running Query From Shortcode Using Tribe's Events Plugin

I am not getting any results back using this code, even though I am passing in correct values. Can someone please take a look? function webinar_list_shortcode($atts) { global $post; // Defaults ...
0
votes
1answer
64 views

Order posts by date and then by custom field

I am trying to do something like this one. Ordering posts by day (not time) AND meta value I want to list blog posts ordered by date (not time) and then within that day, I want to sort them by custom ...
0
votes
2answers
40 views

w3 total cache and post__not_in

I'm using a modified version of the Recent Posts plugin together with WP Total Cache. I'm using post__not_in as I don't want to display the current post again. It works well, but if Object Cache is ...
0
votes
0answers
25 views

Custom post type single display is ommited

I've created a custom post type: tutorials using generatewp.com generator and registered it with register_post_type(). I'm querying the list of tutorials in a custom page template like that: ...
0
votes
1answer
21 views

Change 'post_modify' with a query

I'm trying to change the value of post_modified columns with a query like that: $wpdb->query( "UPDATE `$wpdb->posts` SET `post_modified` = ".$data_modifica_post." WHERE ID = ...
0
votes
0answers
38 views

Year based WP Query

I am am having a strange issue, trying to get year based posts in wp_query, when i do directly, 'year' => '2014' it works fine, but i have the year stored in a variable, $year, then i do 'year' => ...
0
votes
1answer
54 views

WP_Query: Posts within category OR custom post type

I don't like to bother you guys, but this is already driving me nuts. I have a legacy post model within a specific category called 'listas-2' that used shortcodes to show some fancy things. Now I ...
1
vote
1answer
103 views

Ordering by meta_value AND date NOT WORKING with wp_query

I want to select posts and custom post type with a specific meta value (mb_home!=0), of last week and ORDER them by mb_home. If they have the same mb_home value, I want them to be ordered by date. ...
2
votes
1answer
104 views

Meta query with string starting like pattern

I have a custom WP_Query with the following meta_query: $meta_query = array(); $meta_query['relation'] = 'AND'; if(!empty($postcode)) { $meta_query[] = array( 'key' => 'postcode', ...
0
votes
1answer
184 views

WP_Query on custom post type not displaying, multiple loops & get_template_part

I'm having problems getting my testimonials to display. On page.php I have a testimonials section. So I have a loop that grabs the content for page.php, and then a get_template_part('content', ...
0
votes
1answer
36 views

An archive page without post format (just standard post)

I'm trying to get posts with not marked with any type of post types (aside, audio etc). But I didn't find any solution to do this. I thought doing this with custom fields but site has a lot of ...
2
votes
1answer
38 views

Show posts without term

I am working on a product page where I show reviews from my post type 'reviews', if the product page title matches with my term from the taxonomy 'review-product'. Example. Product page title: ...
0
votes
1answer
16 views

Post__not_in only removing first 2 pages

I am using post__not_in to remove pages from a query but it's ignoring anything more than 2 items My code: $selected_check = array(); $checks = new WP_Query( ...
3
votes
1answer
139 views

Combining two wordpress queries with pagination is not working

I am trying to combine two WordPress queries but it's not working as well as pagination. I want to display today's all posts sorted by comment count and after that I want to display all posts ...
0
votes
0answers
31 views

How to get rid of extra Untitled Article in html5 document outline when using new WP_Query?

Here is a simplified version of the code I'm using on a static homepage template made for a child theme of TwentyTwelve. I simplified some of the divs used for styling and just focused on the problem ...
0
votes
1answer
21 views

Display post format post in the sidebar

I am trying to pull posts with the post-format of "quote" on my sidebar. I'm getting the code to spit out the else statement but that's about it so far. I am working in the roots theme if that helps ...
-1
votes
2answers
61 views

Query: offset post list, unless it's a specific category

Here's my code: <?php query_posts(array ('showposts' => '1', 'cat' => '-11')); if (have_posts()) : while (have_posts()) : the_post(); get_template_part( 'content', 'archives' ); ...
2
votes
3answers
107 views

PHP memory friendly alternative to get_posts()

I was running into memory issues with this: get_posts( array( 'posts_per_page' => '-1', 'post_type' => array( 'product', 'product_variation' ) ) (there are thousands of results) just trying to ...
6
votes
2answers
244 views

Is it possible to query all posts that don't have an attachment?

I want to get a list of all posts that don't have an attachment and delete them. This question takes about getting all posts that have an attachment, but I want the reverse of it. The brute force ...