"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
10 views

Custom Plugin - Query CPT - Display Results

This code is going into a sample Plugin I am creating as a test using CPT and print them to a Page. I have been trying to get print_r() to give me an object. The custom post types are posting - ...
0
votes
0answers
6 views

Exclude posts by a guest author still making it accessible from direct url

How to exclude posts by a guest author from category, archive, search and tag pages but still accessible from direct url. I do not want to delete these posts, but is it possible that they are not ...
0
votes
0answers
14 views

Query posts from multiple post types sorted by overarching menu order

I have three different post types named activity, publication and project. I want all posts from these three post types to appear on one page on my website ordered by an overarching menu position. ...
0
votes
0answers
21 views

WordPress ignoring LIMIT / posts_per_page despite being in wp_query

Using WP query: $myquery = new WP_Query( array( 'posts_per_page' => $instance['count'], 'meta_key' => 'mywp_post_views_count', 'orderby' => 'meta_value_num', 'order' => ...
0
votes
1answer
15 views

How to extract information from a wp_query result?

Background: I'm using a wordpress theme called skt full width. I am modifying their front page slideshow, so that it displays six random images instead of six pre-selected images. I have a custom ...
0
votes
1answer
16 views

How to get to a specific position in wp_query?

Background: I'm trying to display images in a slideshow, and I want to select those pictures randomly from the website's media. The image has a custom field in order to be selected for being the ...
0
votes
0answers
27 views

Proper Array Setup

I'm having real trouble getting this to function right, basically I'm tweaking an array for the related products section of WooCommerce for WP, but it's not really a plugin issue more of a general ...
1
vote
1answer
38 views

Use 'parse_query' filter to show posts that from multiple criteria

I am trying to filter the Posts page in the WordPress admin to show posts that meet the criteria for "A" -or- the criteria for "B". I've scoured documentation and can't find a good way to do this. ...
0
votes
2answers
33 views

How to access $wp_query object from array of posts given by get_posts?

I have a simple custom query driven by get_posts: <ul> <?php $args = array('post_type' => 'event', 'numberposts' => 6 ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : ...
0
votes
0answers
23 views

How can I display excerpts of my Recent posts on my static homepage?

I am using the openstrap theme. I want a static home page on my Wordpress website, I have already set this up and have a bit of content on it, the next step is I want to have atleast 4 most recent ...
0
votes
2answers
27 views

ACF accessing a field from the query, but not in post

I'm not sure if this is possible - but checking before re-writing the template. I've extended wp_query to allow for a geocode/location search to be performed. This is working in itself and returning ...
0
votes
1answer
21 views

Custom navigation : show posts in sets of 4

I am trying to reproduce an existing site design in wordPress. The site has a sidebar navigation that shows 4 posts at a time, see here: http://www.davidrich.net/david-rich-paintings/1-1 I you click ...
0
votes
0answers
23 views

Geo location query inside wp_query?

I am building a simple property search website using Wordpress. One of the requirements is for a search tool to search for properties available for sale / to rent based on number of bedrooms etc. ...
0
votes
1answer
13 views

List all Custom Post Type posts excluding certain Taxnomy term

I'm writing a theme in which I've registered "Services" as Custom Post Type that supports "Type of Service" Custom Taxonomy. I want to list all the posts of type "Services" except those which have ...
0
votes
0answers
13 views

No increments in counter in wp-query

I am trying to show related posts outside loop on a single custom post type post in an ordered list. I am using the below code but somehow it does not increment the numbers. <?php ...
0
votes
0answers
20 views

WP_Query with meta_value_num and meta_query not paged correctly

I have a strange thing with my WP_Query, where isn't paged correctly. $args=array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $limit, // 10 ...
0
votes
0answers
17 views

Optimising specific Query with ACF meta objects

Is there any way I can improve the following query without touching the server, as it's taking around 5-6 seconds to execute, the SQL is outputing as: SELECT wp_posts.* FROM wp_posts INNER JOIN ...
0
votes
0answers
12 views

wp_query in form method of widget breaks customizer

In the "form" method of one of my widgets I make a query to offer the user some posts to choose from, like this: <?php $products = new WP_Query( array( 'post_type' => ...
0
votes
0answers
13 views

post by Category not working after setting 4 post per page

I am trying to show 4 posts on my homepage that is working fine but whenever i click on sidebar post categories it still shows the 4 post from homepage i.e the filter doesnot works and it shows 4 post ...
0
votes
1answer
19 views

Adding a block with query in homepage

i want my 2 post blocks to show by Categories not recent And not by category. <!-- Latest posts --> <div class="home-section"> <div class="container"> <div class="row"> ...
0
votes
1answer
31 views

Query posts by views on category page

I'm having trouble trying to create a second query on the category.php pages, what I'm trying to achieve is displaying the most popular posts from the current category archive page being viewed. ...
1
vote
1answer
59 views

WP_Query pagination not working in admin area

I've created a custom plugin page. On this page, I list posts using wp_query(). It works fine. I want to add pagination, but it doesn't work, even when I'm using the code provided within codex: ...
0
votes
1answer
17 views

Custom Taxonomy Query by Taxonomny not working

Not sure what's going on - here's a look at my code: $args = array( 'orderby' => 'title', 'show_posts' => '-1', 'posts_per_page' => '-1', 'cat' => $goalsCat->cat_ID, ...
0
votes
1answer
28 views

Function using get_posts() with tax_query not working when called from functions.php

I want to get an array of all the 'bands' in taxonomy 'types', and use the array later on in other functions etc. I have a utilities.php file that I require() in functions.php and it has the following ...
2
votes
2answers
109 views

Syntax to get the Nth item in a list of custom post types?

We have a custom post type testimonial and want to show the 1st, 2nd and 3rd in various bespoke locations on the page. Here's how we would do it if we just wanted to loop over testimonials and show ...
0
votes
0answers
7 views

Time difference error while publishing posts to word press via xmlrpc

I have a blog which i update content on the daily. in addition i have a system that pushes content(posts) to the blog via the WordPress xmlrpc file. My blog and the content pushing software are on ...
0
votes
0answers
20 views

WP_query returns 5 posts whereas 'Blog pages show at most' is set as 10

I have more than 10 posts (CPTs) on my site. The Blog pages show at most option is set as 10, yet the following returns no 10 but 5 results: $args = array( 'post_type' => 'my_CPT', ); ...
0
votes
1answer
39 views

wp_query if have posts show date but not in loop

I have a wp_query set up to show events and I want to show the date if we have posts and if we do not I do not want to show the date. Here is my code: <?php $today = getdate(); ...
0
votes
0answers
10 views

WP Query with multiple posts and meta queries

I have three custom post types: Stories, Venues and Cities. With Advanced Custom Fields I have added a related custom field to each post type. Each Story has a Venue ID and each Venue has a City ID. ...
0
votes
1answer
34 views

Featured image not showing on page

I am new to creating a theme and wonder if anyone can help? I am trying to display all the featured images from posts under a specific category (id=5) on my index page and it's not working using the ...
1
vote
1answer
37 views

Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)

The Problem On a site I built, I opted to use custom fields instead of a calendar plugin to organize my posts in a "calendar". In the beginning this seemed like the most logical way to accomplish ...
0
votes
1answer
29 views

pre_get_posts or $where, which one to use?

i have a custom search widget, that is searching only one custom post type that contain a meta_key that is greater than or equal to 1, in which i am gathering post_id. of all of those post_id(s), i ...
0
votes
0answers
24 views

Combining multiple query arguments into single query_var for permalinks

how Is it possible to combine multiple query arguments into a single query_var to be referenced in the permalink? For example, using the Posts 2 Posts plugin, it takes three query_vars to filter a ...
0
votes
0answers
13 views

Add filter to Orderby Parameter using Array

Using WP-Query, I'm setting the Orderby parameter using an array: $events_args = array( 'post_status' => 'publish', 'post_type' => 'events', 'meta_key' => 'start_time', ...
0
votes
0answers
9 views

I need value of saved meta to display next to the post it is associated with

This code goes on a category page. I display all the posts that belong to a specific category here, one after another. Each post has a meta box which has a drop down, so the user can select one of ...
0
votes
0answers
21 views

Custom Post 'Post Per Page’ Crashing Page?

Has anyone encountered this before? A normal page template with a custom post type query on it. However, when it gets to a set amount of posts the page crashes, white space below where the query sits ...
0
votes
1answer
16 views

What is the difference between these two custom queries?

Could you please explain what the difference is between the following two custom queries? $arguments = array ( 'post_type' => 'post', 'meta_key' => '_count-views_all', 'orderby' ...
0
votes
2answers
23 views

display news with pictures 3 small and one large (loop)

I'm trying to put 4 news with pictures 3 small and one large, have gotten displaying them but the "large" is repeated with the last "small" <?php $b=1; $args = array( ...
0
votes
1answer
9 views

Running a custom query inside another cpt single and trying to grab a variable

I made a cpt "Neighborhoods" for different neighborhoods. On the Neighborhoods archive, you click on one and go to the single. All good. an example url is /blog/neighborhoods/south-austin/ But I'm ...
0
votes
2answers
118 views

How to use the_posts_navigation for wp_query and get_posts?

WordPress have the_posts_navigation function since 4.1.0. But I don't know how to use with wp_query or get_posts. the following code is in a template file of page.wp_query method: <?php if ...
-1
votes
1answer
32 views

display custom post type from register taxonomy

I've created a custom post type via this function: function custom_post_type() { $labels = array( 'name' => _x( 'advertising type', 'Post Type General Name', ...
0
votes
1answer
23 views

WP Query between posts custom fields [duplicate]

I've tried doing a WP_Query based on a custom field, which name is 'date' and value is something like '14/01/2015'. I want the query to give results when 'date' is between today and tomorrow. All ...
0
votes
1answer
27 views

Post Query not working after updating to 4.1

After updating to Wordpress 4.1 I've noticed one of my more complex post queries has stopped working. It's querying from an events post type and returning posts with a standard timestamp of after ...
0
votes
0answers
21 views

Custom query with 'tax_query' and 'meta_key' returning no results

This is s query that I'm using on my website: $arguments = array ( 'post_type' => 'post', 'meta_key' => '_count-views_all', 'orderby' => 'meta_value', ...
0
votes
1answer
31 views

How to detect if query is runned from widget?

I want to know if exists function that detect if some database query run from widget, for example from recent_posts widget or search_widget.
0
votes
2answers
29 views

Order posts ascending with number in title

I have a page where I show the teams of a football club. I order these with 'order' => 'ASC'. But the problem is that the teams order like I want it to. It orders like this: Team E1, Team E10, Team ...
0
votes
1answer
14 views

Iterate through ID's in loop

I have created a custom loop based on category, now I would like to run a function with the specific ID of the current post being iterated through as a parameter. I have.. $secondary_loop = new ...
0
votes
1answer
30 views

Searching post types

Is it possible to take a user input from a search form, use that to search a custom post type via the WP_Query class and then redirect the user to a page template to display the results? For example, ...
3
votes
1answer
77 views

How to get order of posts?

How can I get the order through which the query is done? For example, my woocommerce product archive page is querying by ordering according to the order_by select box (as seen below). How can I get ...
2
votes
1answer
56 views

How to bring specific post to front of wordpress loop?

So, I have a WordPress loop going on. The below code is the template page for the woocommerce product archive page. Here's the use case for what I am trying to find out how to achieve: User is ...