"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

3
votes
2answers
245 views

Extending WP_Query — Optimise SQL query

I'm storing posts, a user follows in a custom table that has the columns id, post_id and user_id. To fetch posts that a user follows I have extended the WP_Query as follows: class ...
3
votes
2answers
189 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()) ...
2
votes
2answers
147 views

How to query different post types in specific order?

I have 3 posts types, articles, news and tips. On the home page I want to query 20 posts in this order: article, article, news, news, tip, ...// same order again until 20 If I use a custom query ...
2
votes
2answers
451 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= ...
1
vote
2answers
120 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 ...
1
vote
2answers
158 views

How Can I use WP_Query to Only Display 1 Post from Custom Post Type if Query Returns Posts with Matching ID in Custom Field

I have searched high and low for a solution and couldn't find anything; hopefully someone here more skilled than myself can lend a hand. I have two testimonial videos (from a video custom post type) ...
1
vote
2answers
71 views

Exclude the first 'n' number of posts of a tag from home page?

Use case (example): Using a separate, custom query my website's home page shows 5 featured posts, tagged 'Highlights (highlights)', followed by the latest posts, from the main query. I don't want the ...
1
vote
2answers
449 views

twentyeleven_content_nav hook no longer outputs navigation link after 3.5 upgrade

After upgrading to 3.5, I discovered that navigation has disappeared outside of the main index page. Theme is TwentyEleven and I've verified that this still occurs after disabling all plugins. ...
1
vote
2answers
208 views

Query last updated posts (posts updated in the last 24 hours)

I'm having some difficulty to find an example of how to create a loop with posts that had been updated in the last 24 hours. My idea is to have a page of posts or perhaps on the index.php a lists of ...
1
vote
2answers
424 views

Loop to fetch 3 post_thumbnail instances from 3 most recent custom post types named “portfolio”

I am trying to display 3 post_thumbnails from a custom post type "portfolio" on my homepage template. So one from post 'A' , one from post 'B' and one from post 'C' The image from post A will be set ...
0
votes
2answers
19 views

Custom Taxonomy Breaks Pages

I have a custom taxonomy called 'industry' that I want to use on custom post type 'website-design'. It works on the intended post type, but other pages are broken. I changed the 404 template as per ...
0
votes
2answers
53 views

query_posts different amount of posts per page

I have a posts_per_page query to paginate multiple post types, which works great! Now though, as it paginates it to show (in this case) 100 posts per page, I'm wondering if you can show 100 on page ...
0
votes
2answers
39 views

Taxonomy related query not working

For all of my pages I have setup a taxonomy field using the plugin Advanced Custom Fields, for which I can then select as Home category, or something else like News. I am using the default category ...
0
votes
2answers
23 views

getting content from main domain to sub-domain using category and WP_Query

I have a main website with 2 sub domains. www.example.com www.space.example.com www.products.example.com I want to publish articles on my main website using categories to sort them. for example, ...
0
votes
2answers
44 views

Pagination not working in secondary query

I'm trying to fix a theme which has the following setup: on each page the user can select to list posts instead of the page content. The problem is that the pagination doesn't work on this page even ...
0
votes
1answer
37 views

How to query posts that are not related to any term of a taxonomy?

Background I'am generating posts from an uploaded csv. Each row is supposed to be a new CPT record which will have a term based on one of its column. This is the stripped csv Post Title;This is the ...
0
votes
1answer
452 views

Site not getting correct featured image from my query

On the home page of my site I have a series of tiles that link to various parts of the site. One tile links to the blog and I have written some code to pull the latest post with an image attached to ...
0
votes
1answer
34 views

Assign a tag to custom post type using a query

I have a custom post type courses with a custom field level. I want to run a query (mysql or WP query) that runs through every course (post) and if the level is greater than 3, append a tag called ...
0
votes
1answer
61 views

wp query problem

I am using wp-postviews plugin to to track views of my post The author provided a query to order post by views in index.php <?php query_posts('v_sortby=views&amp;v_orderby=desc') ?> ...
0
votes
1answer
203 views

Can I make a search query which includes a space?

I want to search via WP_Query for the test "hello " including the last trailing space. Is this possible and if so, how do I do this?
0
votes
1answer
186 views

Pagination not working on homepage

I tried multiple solutions but its not working. When I go to /page/2, it doesn't work. I'm executing custom query in index.php of my theme. if ( get_query_var('paged') ) { $paged = ...
0
votes
1answer
166 views

Get next post when using pagination with WP_Query?

How do i specify which "page" to get when using WP_Query? I'm using pagination and i only display three posts per page, but i need to manually set which page to get, because Wordpress doesn't do that ...
0
votes
1answer
104 views

Query posts by custom fields

I am making a theme for a hotel, and I need to be able to provide functionality to search by the following custom fields: Location and Price. I need to be able to query them from the query string ...
0
votes
1answer
117 views

Loop posts without any taxonomy

I've grouped my pages by some custom taxonomy. But I need to care about those without any taxonomy set. My code is: $page_groups = get_terms('page_group'); //get all existing page groups foreach ...
0
votes
1answer
423 views

WP_Query post at custom position

Lets say I have a custom query which based on two custom post types: $wp_query = new WP_Query(array( 'post_type' => array('post-type-1', 'post-type-2'), 'post_status' => ...
0
votes
1answer
55 views

restrict posts per page

I want to display in a featured slideshow only 3 posts, but it is ignored and it shows a lot of posts. How to fix it? $my_query = new WP_Query( array( 'posts_per_page' => 3, ...
0
votes
1answer
229 views

WP_Query breaks pagination

I've been on this problem for a week now. I've searched through countless posts that just aren't answering the question. It seems that my wp_query breaks pagination. I've looked through a lot of the ...
0
votes
1answer
514 views

Exclude post formats in custom loop

I'm trying to exclude all post formats but standard from a page template loop that displays 4 latest posts. For some reason I can't get the query to work. This is my page template global $paged, ...
0
votes
1answer
255 views

Converting multiple loops into one single loop with pagination

I am using Isotope jquery plugin to filter/sort posts in Wordpress but to correctly filter the posts into the right order I have needed to output each category one after the other. To do this I've ...
0
votes
1answer
67 views

Order by meta values

I have 3 meta fields related to dates: year = 2012 release_date = 14 November 2012 release_date_db = 20121114 I need to show the posts from year 2012 sorted by release_date. I made this: ...
0
votes
1answer
1k views

Duplicate posts showing up in loop using infinite scroll

I'm experiencing an odd issue using Infinite Scroll for the WP_Query loop on my homepage. Half the time when the second page fires, I'm getting a few duplicate posts showing up in the second set. I ...
0
votes
1answer
22 views

How to specify a certain amount of images queried, not all?

I have a query for calling images from a post category. I am trying to control it to only query 6 images. I have tried using php count, but its not working as expected. Any ideas of what I could do ...
0
votes
1answer
194 views

Execute PHP function inside the admin area

I want to ask if there is a hook for executing php inside the admin area, my problem is I'm trying to do the get_posts wordpress function inside a popup frame using the thickbox jQuery plugin, using ...
0
votes
1answer
1k views

forming WP_Query for posts of all post types but from specific categories

I need to get post from blog, custom post type 1, custom post type 2. custom post type 3 and either from category 1 or category 2 or category 3 or category 4 or category 5 or category 6 or category 7 ...
0
votes
1answer
171 views

WP_Query do not include posts with a certain value in a custom field -

I am trying to grab the 5 most recent posts and have it exclude posts in an array that is already defined ($exclude), sticky posts and any posts that are checked off as a featured post (i.e. with the ...
0
votes
1answer
201 views

Attempt to display site authors in a carousel - User Image not Outputting inside li tags

I am attempting to display the authors of my site in a jquery carousel but for some reason my images are outputted outwith the li tags and I don't know why. Code functions.php function ...
0
votes
1answer
191 views

Pagination in wp query with transient api

I have intergrated wordpress transient system with w3 total cache. Now i can`t to do pagination for this query. <?php $paged1 = ...
0
votes
1answer
111 views

wp_pagenavi on WP_Query using customfields

I have been searching this subject for some time now, not finding a solution. First of all, sorry for my bad spelling. Im quit new to PHP, so please be gental. Im using this to list some ...
0
votes
1answer
70 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: ...
0
votes
1answer
699 views

Custom WP Query from meta_value stored as serialised array

I'm using a Magic Fields 2 multicheck box to store Services which can be assigned to Case Studies. The data is stored as a serialised array in WordPress, and I need some help to extract the "related ...
-1
votes
1answer
89 views

WP_Query with tax_query not working

I tried to create a custom query, but no results, it throws me an error. $args = array( 'post_type' => 'product', 'posts_per_page' => 1, ...
-1
votes
1answer
1k 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' ...
-1
votes
1answer
210 views

Pagination with Custom Post Type not working on index.php: I get a 404

I've read many posts about the same problem but none seems to work for me. I have a query for a custom post into the index.php. When I go to page 2 I get a 404 error. The same code works like a ...
-1
votes
1answer
176 views

How to sort custom post type by multiple custom fields?

How to display posts with 'agenda' custom type ordered by custom fields 'agenda_date' and then by 'agenda_time'? 'agenda_date' is date custom fields. agenda_time is text custom fields I tried this, ...
-1
votes
1answer
114 views

Next and Previous buttons are not showing on home page for post

I made a theme from PSD to WordPress but the "next"-"previous" buttons are not showing on home page. Here is the code of single.php: <div id="primary" class="site-content"> ...
-1
votes
1answer
21 views

Are custom posts included when getting a categories' posts?

Would WP_Query('cat=1') display custom post types, or is that something that I have to specify? I have a custom post type, am assigning it to a category, and would like for it to be displayed when ...
-1
votes
1answer
91 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 ...
-1
votes
1answer
315 views

How to write short code with if else to get page_id?

<div class="group-training"> <?php while ( $page_loop->have_posts() ) : $page_loop->the_post(); ?> <div class="entry"> <h1><?php the_title(); ...
-2
votes
1answer
137 views

Pagination on custom post type not working

I'm having a hard time getting pagination to work with my custom post type query. The standard "previous_posts_link()" and "next_posts_link();" aren't working. And through a bit of testing, I've ...
-2
votes
1answer
141 views

Get all user with both meta_value

I was wondering if there were any efficient way of fetching all user comparing two different meta_key. I am currently fetching all user compared to the first meta, then loop trough the user_id to ...