"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

1
vote
0answers
9 views

Related posts by author pagination not working on the production site

The code that I'm using has adapted from this example and successfully tested on my localhost but when I pass the site to a live server, the pagination crashes with wordpress permalinks set (/% ...
0
votes
0answers
10 views

Meta Query querrying several post types based on ACF fields is broken after update to WP 4.1

I was using the following arguments for a WP_Query for months: $args = array( 'post_type' => array( 'posttype1', 'posttype2', 'posttype3', 'posttype4' ), 'posts_per_page' => -1, ...
0
votes
0answers
15 views

WordPress database error Duplicate entry 'cron' for key 'option_name' for query [on hold]

Today i see the error's with my website and it seems to slow down the performace of the website when i was having very high traffic on the website. I bought Vaultpress plugin for the backup and i was ...
0
votes
1answer
37 views

Cannot order by in WP_Query

I'm stuck with this issue : I'm having a custom query in which I cannot order by anything. I want to order by a specific meta_value. But event when ordering by name, title, date etc, I still can't. ...
3
votes
2answers
32 views

Using WP_Query To Get Posts Randomly From today

In the logic of the data_query(); I found this WP_Query sample: <!-- Second Senses Featured --> <ul id="featuredSecond" class="featured-second"> <?php $today = ...
0
votes
1answer
16 views

Display all attached image of every post of custom post type and link to original post

I've written a loop that displays all the images that are attached to every single post of a specific post type. The post type is called "atls_events" and I'm outputting an image size called ...
0
votes
0answers
21 views

WP_Query is being reset after <header> tag (using chaining method)

I'm creating a page template. In this page template I create a custom query. - page-recipes.php: <?php /** * Template Name: Recepten - archief * chained with /archive-recipes.php * */ ...
0
votes
2answers
18 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
1answer
15 views

Use custom get results query to show posts WordPress

I have this code before to show posts. $query_args = array( 'post_type' => 'post', 'posts_per_page' => 4, 'meta_key' => 'Views', ...
0
votes
1answer
20 views

Filter and Order by Multiple Custom Meta Values

I am trying to query a custom post type, order by a custom meta value, and only display posts with a different custom meta value. I am able to do each independently but not both at the same time. ...
0
votes
1answer
19 views

2 queries with counters

I have 2 loops on a page both containing a counter to implement slightly different code every 6 posts. For some reason though the second loop is implementing the different code sometimes after 4 items ...
0
votes
0answers
20 views

Pagination is not working on custom query inside a custom home page template

I know this is a duplicate question. But to comment on existing question, I dont have enough points. So here we go.... Pagination is not working on custom query inside a custom home page template. ...
2
votes
1answer
16 views

WP_Query search custom posts meta date fields

I have a custom post type which stores dates in a meta field as 2014-02-22 22:38:00 I can use WP_Query to find posts created in a certain month / year $args = array( 'post_type' => ...
1
vote
1answer
52 views

Overwriting posts_per_page in new WP_Query

I've tried for hours for a solution to this. Here's the problem, I have a theme that is using new WP_Query to set up a loop. That works fine. I want to take the original query, modify it, and then ...
0
votes
1answer
40 views

New WP_Query not isolating custom post types on front-page template

This is the code for my front-page.php template <?php add_filter( 'genesis_markup_site-inner_output', '__return_false' ); add_filter( 'genesis_markup_content_output', '__return_false' ); ...
2
votes
2answers
70 views

Can wp_query return posts meta in a single request?

I would like to create a wp_query that would return posts meta inside the posts array. $args = array ( 'post_type' => 'page', 'meta_key' => 'someMetaKeyName', ); // The Query $query = ...
1
vote
2answers
24 views

wpdb custom post_type problem

I want to use custom post type in my custom SQL query, but, when I add the custom post type im my query, I get no results. Where's my probelm ? This is the code I've tried $top5_ov_performance = ...
0
votes
1answer
39 views

How to query posts by meta keys AND under specific category?

The scenary: I'm working in a review system for WordPress, a game review website. It uses default posts, that when under "review" category, shows the review's meta fields (from ACF plugin). It's ...
0
votes
1answer
13 views

Get category name from custom loop and echo it once

I have a magazine front page that updates with every issue, and the front page shows the current issue posts which are stickied. So for example, this month all the posts are in a category titlted ...
0
votes
2answers
51 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
0answers
26 views

How to sort a WP_Query array by post_name after an array_merge();

I have an WP_Query array made up from two WP_Query() objects merged together as follows: $query1 = new WP_Query($args1); $query2 = new WP_Query($args2); $wp_query = new WP_Query(); ...
0
votes
0answers
20 views

How to query post by type and slug?

I have the following WP-query on my Wordpress website (via WP-API) and for some reason it returns me an empty array: array(6) { ["post_type"]=> array(1) { [0]=> string(9) ...
0
votes
1answer
18 views

Trying to Exclude Sticky Posts From date_query

<?php $lastThirty = date('Y-m-d', strtotime('today - 30 days')); $currentMonth = date('M Y'); $t = date('d-m-Y'); $today = date("D",strtotime($t)); $lastThirty = array( 'date_query' => ...
0
votes
2answers
36 views

What is the best way (regarding performance) to set transients for logged in users?

I have an option for my logged in users where they can hide the posts they dont want to see. Everything works as expected until I implement transients. When I set the transients to cache the posts ...
0
votes
1answer
20 views

Use posts_where to exclude posts ids from wp_query

I want to use posts_where to exclude an array of posts ids from all queries in my site. The array containing the posts ids depends on the user that is logged in. Can someone please tell me how to ...
0
votes
3answers
39 views

WP_Query - Object manipulation vs WordPress functions

Although this could be opinion based, there must be a some consistent way / optimised way of manipulating data from a WP_Query. For example, the 'best' way to get a posts title? $query = new ...
0
votes
2answers
38 views

How to count number of records found in a database table?

I am new to wordpress development & tried to learning plugin development.I have created a custom table from which i want to show the number of records found.I have tried the below code but it ...
0
votes
0answers
23 views

Filter media attachments by post in Media Library

Were working on a small plugin to allow attachments in the media library to be filtered by the post that they are attached to - and the basics are working: You can see the full code hosted on github ...
1
vote
1answer
28 views

No results found from a $wpdb->get_results() query when trying to join more than one meta key query

That title was a real mouthful. I have a custom post type called work with three custom taxonomies called work-client, work-type, and work-service. I'm using Advanced Custom Fields to make a nice ...
0
votes
1answer
35 views

How to do a loop inside a loop?

I'm trying to get posts from a custom posts using WP_Query. <ul> <?php $query1 = query_posts( array( 'posts_per_page' => -1, 'post_type' => array('specialties') )); ...
1
vote
1answer
46 views

WP_Query with two post types, but requiring category on only one of those post types

I have a simple WP_Query: $loop = new WP_Query(array( 'post_type' => array('image', 'video'), 'category_name' => $cat, 'meta_key'=>'total_votes', ...
0
votes
0answers
20 views

Shortcode display CPT Query only showing 1 post?

Ive seen similar questions on here but I am already using WP_Query and wp_reset_postdata. In short I wrote a shortcode that queries our Custom Post Type to display posts specific to a category. ...
0
votes
0answers
13 views

how post by category related to archive post date - how to?

I'm having a really bad time to make this work .. I have a archive template, which works fine (build by custom-post-type, call archive), the archive section works perfectly, and dsiplay my post in ...
0
votes
0answers
29 views

Filter Posts using Letters in archive page

I have created an archive for a custom post type called archive-artists.php. I want to achieve the following: Implement an A-Z letter control which filters the posts based on the letter selected by a ...
1
vote
1answer
122 views

What's faster? One big query, or several smaller ones?

I'm working on an app that will require a query, via Ajax, for a bunch of posts in random order. Something like this: $query = new WP_Query( array( 'posts_per_page' => 50, 'orderby' => 'rand' ...
-2
votes
1answer
62 views

WooCommerce Only OnSale Products Loop Snippet [closed]

I am trying to pick only OnSale products in a WooCommerce loop through a snippet. For that I tried to use below code but this one is picking all products. I only want to pick OnSale products in loop. ...
0
votes
1answer
40 views

Load 3 posts in flexslider slide [closed]

I have a slider that i'd like to load 3 blog posts into each slide. I'm having a problem getting them all out correctly. I'm using Flexslider. The idea is to get 3 blog posts at a time into each ...
0
votes
0answers
52 views

Multiple Loops on category.php with pagination on last loop

I'm trying to achieve what should be fairly simple but I've hit a brick wall when trying to paginate the last of three loops on the category.php template. I've read just about everything I can find on ...
0
votes
0answers
23 views

Wordpress WP_Query post__in

I try to get value from database==> postmeta ==> Meta value : value Using this code $promo_value = $wpdb->get_results("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = '_product_id' ...
0
votes
0answers
4 views

any way to bind a taxonomy term to o user to just query it afterwards?

I need somehow to add an existing term from an existing taxonomy to a user like a category of users, but not for the purpose of limiting them to posts is that easily possible? I found some plugins ...
0
votes
0answers
78 views

Overwriting auto-appended NOT IN query in WP_Query

When I try to grab bbpress topics AND posts in the same WP_Query, Wordpress automatically appends a NOT IN query to make sure the topics are not in private forum categories. However since posts ...
-1
votes
0answers
25 views

query post_per_page for current archives

I'm trying to define the number of post to display in my slider for my archive templates. here is the code: <div class="flexslider"> <ul class="slides"> <?php ...
0
votes
1answer
66 views

Sort Order for a Custom Query in a Post Type Archive Not Working

I have a custom post type for events set up and am displaying the posts in a custom post type archive "archive-events.php". I am using Advanced Custom Fields to put an event date "event_date" on ...
0
votes
0answers
24 views

Adding nav_menu_item id to Wordpesss links and wp_query vars

having a bit of an issue with this. What I want to achieve is this, the user clicks on a menu item and the menu item's id is available in the $wp_query vars. I also want to achieve the same with any ...
0
votes
1answer
92 views

WP JSON REST API (Ryan McCue) how to query posts with specific meta data with 'AND' relation?

I use Wp_query class to query my posts. 15 posts are in a template fetched on page load and their filtering works fine. Infinity scroll fetches for other posts using JSON restful services. The filter ...
-1
votes
0answers
62 views

display post of the year/month/week in slider for archive template

I'm building a archive template, which show the post by year; month; and week. However, this archive template has a slider, which as the moment display the last post created - so it doesnt match the ...
0
votes
1answer
74 views

Loop through multiple custom fields with increasing number

I have a problem with custom fields that I have been trying to figure out for a while, but with no luck. I have a section on the site I'm building that let's the users publish content form the the ...
0
votes
1answer
19 views

How to set parameters for search loop?

This is the loop from search.php file: if (have_posts()) { while (have_posts()) { the_post(); I tried to set parameters like this: $wp_query->set('post_status', 'publish'); ...
0
votes
0answers
36 views

dynamicaly populate a WP-Query Argument

Hi Ive the following code for a single Taxonomy term template, its all working fine, however i'd like to adapt it somehow to get the argument 'term' dynamically, so get the current term, update the ...
0
votes
3answers
37 views

Comment count same for every post in homepage WP_Query

I have a WP_Query on my homepage template that works just fine for get_the_title() and MANY other functions for each post in the loop. However, any way of getting the comment count just grabs the ...