"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

2
votes
1answer
18 views

Sorting a list of posts displayed under a list of associated terms (which should be sorted without initial articles)

I have series of sorting issues on a page that I'm trying to figure out but so far to no avail. Sorting a list of CPT posts which are listed under associated custom taxonomy terms I found this piece ...
0
votes
1answer
16 views

wp_query with different postmeta filter for each categories

Let's say i have categories (cat1, cat2) and i have postmeta keys (date1, date2, status). How do I view all posts in all categories with these filters: For cat1, i want to apply WHERE date2 <= ...
0
votes
1answer
9 views

Display Year and Month from custom field + Age Calculator

I have a custom field "DOB" on my custom post type which is in [Ymd] format. I want to compare that date of birth to current time and want to show "You are # years # months." I am able to calculate ...
1
vote
1answer
20 views

Storing posts from query and accessing later via AJAX call

To clarify the above question title, what I am trying to do is create a grid of posts, for which I am displaying a thumbnail of an image that is attached to that post. Then, upon clicking each of ...
1
vote
1answer
26 views

Pagination causes error 404 when used with front-page.php

I am creating front-page.php. This page will display the latest featureed posts, and will also have pagination option to go to the previous featured posts. I wrote the code for frontpage as follows ...
0
votes
0answers
18 views

How to display an other custom post type in a different custom post type's archive?

Background: I need to display all posts of a custom post type called "recipes", that have a specific taxonomy "fish", right under the permalink "www.mysite.com/recipes/fish". What I have done: I ...
0
votes
1answer
40 views

Two near-identical custom field types - one works, the other doesn't . What can cause this?

I'm using Advanced Custom Fields to add meta information to a custom post type and in ACF I've created two different 'Select'-dropdowns - one is called 'series' the other 'classification'. I run a ...
0
votes
2answers
63 views

WP_Query results stored in variables

I'd like to know if there is a way to store WP_Query results in variables that I can then go ahead and insert anywhere on the page outside of the loop. For instance, say I want to get the feature ...
0
votes
0answers
16 views

meta_query against multiple custom fields

I have a set of ACF custom fields: event_type (values are "single" or "multiple") event_start_date event_end_date (this only shows up if event_type is set to "multiple") I need to be able to show ...
1
vote
0answers
18 views

First custom field value (out of several) displayed twice after query

I have the following piece of code, which is based on the solution to this question: <?php $game_titles = get_terms('game'); foreach($game_titles as $game_title) { ...
1
vote
2answers
42 views

Create WP_Query to search for posts by their categories or their parent/child categories

Hello I am really sorry if this has been asked before but I couldn't find the exact solution I need. So here's the problem I want to create a search in my Wordpress page. Whenever a user submits the ...
0
votes
1answer
40 views

Sort results without WP_QUERY?

I am new to coding a WP_QUERY and I tried a few things with it but it doesn't seem to work. Right now (you can see the page here: http://boomerang.mannydesigns.co/artistes/parcourir/musique/ ) I need ...
0
votes
0answers
14 views

Create select dependent dropdown by meta values or categories

We had 3 custom fields Brand Model Features (multi input in an array ) need dependent drop down form when select Brand (or Category) > show drop down menu contain all Models (related to this ...
0
votes
1answer
13 views

Retrieve posts using thumbnail id as meta key

I am working on my website and using these args in wp_query but I also want to show only those posts which have thumbnails in it... here are the args I am working on: $args1 = array( ...
7
votes
3answers
275 views

Ignoring initial articles (like 'a', 'an' or 'the') when sorting queries?

I'm currently trying to output a list of music titles and would like to have the sorting ignore (but still display) the initial article of the title. For example if I had a list of bands it will be ...
0
votes
0answers
6 views

Query Code Making Menu Disappear

I'm trying to display only certain tags on my site, but when I use the code my menu disapears. Heres what I have: $query->set('tag', 'break','crunch'); return $query; I have this placed in the ...
1
vote
0answers
35 views

wp_reset_postdata() and wp_reset_query() inside shortcode are not working to reset original page query

I'm implementing a form for a frontend post with a shortcode. The form is processed in the same function, reloading the page: function adicionar_ninhada(){ $user_id = get_current_user_id(); if ...
1
vote
1answer
30 views

How do I Use Nested Loops of Custom Post Types for MultiSite Blogs using WP_Query()

I'm using the code from miguelpeixe's 'WordPress Query Multisite' in order to create a custom loop for my WP Multi-site's 'child sites.' Within this loop, I want to nest another loop that will pull ...
0
votes
1answer
48 views

Meta Query with date and time on the same Day before given time

I have a metaquery for a custom post type "events". Their start date is stored as a meta field in this format: 2016-02-05 19:00:00 These are my query args: $args = array( "posts_per_page" ...
0
votes
2answers
34 views

Advanced WP_Query with meta_query, orderby?

I wonder if anyone can help me with this little complex query with ACF. I have the following so far which should display: Pages, News Articles, About Articles and Involved Articles. Show: only ...
-1
votes
0answers
29 views

$wp_query filters with html input

I am stuck in add filters to $wp_query with inputs from html. Like when user enters a string in input box & the query is filtered with each letter. Any suggestion will be appreciated. Scenario ...
1
vote
2answers
60 views

new WP_Query() - what is the earliest valid hook?

Specifically, is it valid to run a new WP_Query() during the plugins_loaded action?
1
vote
0answers
19 views

Random ajax load only works with posts_per_page set to -1

I created a post loader shortcode, that uses AJAX to load posts. Even though I can set the order and order_by query parameters, the order_by should be random. From what I've seen on the web, ajax load ...
1
vote
2answers
45 views

WP_query to get the first two latest posts, then another loop to get the next three

My ultimate goal is to list the latest 5 posts, regardless of category. I would first like to make a WP_Query to get the latest two posts and insert them in to a specific HTML structure. Then I ...
1
vote
2answers
37 views

Clean up WordPress code that repeats

I want to use the following code multiple times in the same page template, however the template gets too big when it comes to lines of code and therefore size. Every time I use it I change only one ...
1
vote
0answers
24 views

Array Chunks and Inserting Varying HTML in WP_Query

I am trying to output the latest 5 posts from my blog. I would like each post thumbnail to populate divs in the following format. <div class="row full"> <div class="large-6 medium-6 ...
0
votes
1answer
26 views

WP_Query arguments relation shows AND instead of OR

In wp_postmeta I have a meta_key which stores colon separated strings such as "CA:Georgia:NY". So for meta_key='state' there can be several entries like: For post 1 = "CA:Georgia:NY' For post 2 = ...
1
vote
0answers
23 views

Exclude Category filter from Portfolio section

I am stuck with this since hours and found lots of forum entries about NOT IN, WP_Query, category__not_in portfolio, editing JS/ CSS in Theme options or having bits of code to add to portfolio.php, ...
5
votes
1answer
59 views

How does reset_postdata restore the post of the main query loop?

How does reset_postdata works? The docs say: restore the global $post variable of the main query loop after a secondary query loop using new WP_Query But in the class, it takes the "current" ...
-1
votes
1answer
16 views

Where to find WP_Query class?

I cannot find WP_Query() in my wordpress folder, the global refers to $wp_query but I don't find the class itself. From my wordpress folder, or here directly : ...
1
vote
0answers
18 views

Custom Taxonomy and tax_query Issue?

I am working on Plugin development and my plugin name is plugindev.I have a custom post type called team.I have a custom taxonomy Team_Category which is being registered by this code ...
1
vote
0answers
18 views

Prioritize posts in query by meta keys?

I have a CPT called jobs. In my single jobs page I am counting page views with these functions: /********* Post Views counter ***********/ remove_action( 'wp_head', ...
0
votes
1answer
15 views

How to order by datediff in WP loop?

I have a custom post type for events with a custom field named event_start_date, and I want to sort the archive loop according to the nearest event_start_date. In other words, the event with the ...
1
vote
1answer
34 views

WP Query with custom Shortcode

I have the following in my functions.php:- /** * Shortcode: Latest Properties */ function latest_properties_func( $atts ) { $args = array( 'posts_per_page'=> 5, 'post_type' ...
0
votes
1answer
26 views

Query with two posttypes and two different meta_keys

I need to query two custom post types, like this: 'post_type' => array ('single_events', 'group_of_events'), and i need to select certain posts in a certain order, to do this i wrote a meta ...
2
votes
4answers
71 views

Trim first 2 words of the exceprt

I am currently pulling in the post excerpt however there are 2 words at the start of it that I would rather not have in this particular place as there is a title already. I have used wp_trim ...
1
vote
0answers
18 views

Lists Posts from CPT that match the Title of the Page

I am trying to get all the posts associated with the Title of a page. This is what I currently have: <?php $title_to_tag_posts_query = new WP_Query( array( 'tag' => ...
1
vote
0answers
8 views

auto-populating custom nav with all items from custom post type

I have written the following code to take all of the posts in my custom post type "products" (created with ACF) and inject them each as an <li> in a custom nav menu. Everything is working ...
1
vote
0answers
35 views

get product title ID and price and product picture woocommerce by cat-id query select mysql

i have query that return categories in woo-commerce like this: SELECT wp_terms.term_id AS id, name FROM wp_terms INNER JOIN wp_term_taxonomy ON wp_terms.term_id = wp_term_taxonomy.term_id WHERE ...
0
votes
0answers
20 views

Custom query for tag and custom tag from 2 post type

I have custom post type called items and added custom taxonomies type and sub-type. I like to query posts from both post and items post type that has art as either Tags or Sub type. Below is what ...
2
votes
0answers
12 views

Generate a tabbed submenu — from taxonomy term or submenu item — with sample content

I'm looking to generate a tabbed submenu from taxonomy term or submenu item and include sample content (three items per term/submenuu item). The styling I can do, the problem is the html generation. ...
1
vote
1answer
17 views

Get posts from WP_Query and format them on admin_head

I am trying to prepare an array with Custom Post Type posts to populate a select options in TinyMCE. I was thinking to fetch posts, get their IDs and titles and put them all inside $data variable, ...
1
vote
1answer
23 views

Wp query show post by author name or post title or post content

I have to create a search query which allows me to filter all posts where author name and post titles or post content has the word from search textbox. So if i search wordpress it should list all the ...
0
votes
1answer
20 views

query_vars empty when using custom url with custom rewrite rule

I'm trying to pass custom url parameters to pretty urls using add_rewrite_tag('%product%', '([0-9/]+)'); ...
5
votes
2answers
73 views

How to list some posts first in the loop based on post id

I have a query for to display some posts . $args = array( 'post_type' =>'products' 'posts_per_page'=> 12, 'orderby' => 'meta_value_num', 'meta_key' => '_price', ...
-1
votes
1answer
37 views

Standard Loop - wp_query

I was readind this article (https://codex.wordpress.org/Class_Reference/WP_Query) and try run the Standard Loop, but I can't receive the any result. My code is this: <?php get_header(); /* ...
1
vote
1answer
24 views

Sort by meta key on archive page

I am trying to sort an archive page using a meta key value (which happens to be a Unix timestamp). Currently I have the posts listed on the page by their WordPress creation date. I want to use the ...
1
vote
0answers
24 views

Search form not working with custom query?

My search query doesn't seem to work, the query in my url is all correct but the content just refreshes without finding the posts with the search term.. I got a custom search query and a function to ...
0
votes
0answers
22 views

Lazy loading Ajax offset not working

I am attempting to create a lazy loading ajax feature on my site. There is a 'click more' button which will then load 10 posts via ajax and append them to the HTML container. I want to display 10 ...
0
votes
0answers
15 views

query order by a function

I was wondering how to order posts by a function that returns a number. I've set up a query and i want to order my post by that number. Here is what I have: $foo = get_like_count(); and in the ...