"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
0answers
3 views

Conflict with get_posts and the_content

I have this snippet in my header.php to display a slider: <?php $args = array( 'post_type' => 'post', 'posts_per_page' => 6, 'meta_query' ...
0
votes
0answers
2 views

how to load posts to a custom post template after using template_redirect or template_include

I need to use the URL parameter ?m=1 to load every page of my wordpress with a different template but the problem is that I can't pull the text and posts that can be accessed using the canonical URL I ...
-1
votes
2answers
43 views

Limit the number of posts via wpquery

We suppose that a category has 1000 posts, we can use the following code to show 10 posts per page and the wp pagenavi would present 100 pages with links of above 1000 posts. <?php ...
0
votes
1answer
27 views

WP_Query condition affects posts_per_page count

I'm trying to create a new WP_Query that displays the last 5 posts from cat 1 that doesn't have a thumbnail. This actually works: <?php $the_query = new WP_Query( 'cat=1&posts_per_page=5' ); ...
0
votes
1answer
18 views

wp_query with multiple custom fields

My Query is this: $products = new WP_Query( array( 'post_type' => 'ys_product', 'orderby' => array( 'date' ), 'order' => 'DESC', ...
1
vote
1answer
22 views

How to search for posts IN OR title OR content OR author?

I have looked at many posts and questions regarding searches for custom meta, but I want to search for posts and include those if the search query matches an author name. I have come up with the ...
0
votes
1answer
24 views

How to query using a combination of custom_field values?

I need to get posts pertaining to a given category, AND : have the event_start_date (custom field) greater or equal than today's date OR have a event_end date (custom field) greater or equal than ...
1
vote
1answer
45 views

convert custom query to wp_query

My query is as below $querydetails = " SELECT wposts.* FROM $wpdb->posts wposts INNER JOIN $wpdb->postmeta wpostmeta ON wposts.ID = wpostmeta.post_id INNER JOIN ...
0
votes
0answers
14 views

Add custom WP_Query after the first 3 posts

In my main loop I want to add a custom query after the first 3 posts. I managed to do this -- code will follow -- but I have one problem: instead of adding the new posts after the third post, my code ...
0
votes
1answer
39 views

Custom Post type and Custom Field WP_Query

I am developing a site for a client who is a Youth Football (Soccer) Club, with lots of different Teams depending on the abilities and ages of the children. I have added in a Custom Post Type called ...
1
vote
1answer
32 views

Wrong request query on cpt and tax

In my plugin I think that I use pretty much standard and documented way to add my custom post type and two tax (cats and tags), but only thing that I do is set custom capability_type and perms. Here ...
0
votes
0answers
8 views

Loop tags with specific design

Forgiveness for the title, I can not think of anything to describe it. First I have a basic loop: <?php $args = array ( 'category_name' => 'juego-de-tronos', 'orderby' ...
2
votes
1answer
60 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
1answer
38 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
21 views

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

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
41 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
44 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
21 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
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
1answer
18 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
29 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
20 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
1answer
33 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
20 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
58 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
49 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
75 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
26 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
40 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
14 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
54 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
27 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
38 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
21 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
40 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
41 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
25 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
29 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
37 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
49 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
21 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
14 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
123 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
66 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
42 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
58 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 ...