"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
1answer
59 views

WP_Query: Why is sticky post not first item in loop?

I've got a custom WP_Query loop based of meta_value variables: $meta_cat = get_sub_field('category'); $posts = new WP_Query( array( 'cat' => $meta_cat, 'posts_per_page' => ...
0
votes
1answer
21 views

Random posts in WP_Query when searching by tag

I have a section that want to include featured posts. I want to look for featured posts based on tag. For example, I want to fetch all the latest posts that have the featured tag. I use the following ...
0
votes
1answer
28 views

Create a hierarchical loop at predefined markup requirements

I try to achive this in wordpress based on my theme: fullpage.js demo So I have a predefined markup for vertical sections (parents) and one for horizontal slides (children). Parents only contain ...
0
votes
1answer
32 views

WP_Query() load selected post

I need to load a selected post in a ajax function, I have some problems writing the appropriate query that calls the post i'm pointing <?php $pb_id = $_POST['post_id']; $pb_details_args = ...
1
vote
4answers
101 views

2 loops on page - one with orderby rand second orderby date

What I'm trying to achive, is to set 2 loops on one page. First one takes 11 latest posts and sort them in rand order. Second show the rest of posts ordered by date. FIRST LOOP $args = ...
0
votes
0answers
36 views

Get wp_taxonomy_term inside WP_Query throwing an error

I am using Elastic Grid in my site. When I am coding in to the WP it is giving me an error saying K.data(...).split is not a function Here is my code, $(function(){ ...
0
votes
1answer
55 views

Get query result according to merged array

1st query selecting the records that are found $old_args = array( 'post_type' => 'product', 'meta_query' => array( 'relation' => 'AND', array( 'key' => ...
0
votes
1answer
25 views

How To Use WP_Query To Get The Custom Post type Posts With Keywords

I want to query with keywords and display some related posts on custom taxonomy page, the related posts comes from a custom post type "gift". I have tried the code below, but it only worked for ...
0
votes
1answer
21 views

echo var into wp_query

Im trying to echo out a value grabbed from a ACF field but I think im doing something wrong, could someone help me? <div class="news"> <div class="container"> <div ...
0
votes
1answer
74 views

Get a list of ACF Repeater-Fields as array

I run a Site for a concert & music club. Events are set within a custom post type called "events". In this i set the date, the name of the event and all other infos about that event. In this ...
0
votes
0answers
28 views

Displaying Custom Taxonomies that match other posts taxonomy

Here is my setup....I have a custom post type that has 2 custom taxonomies (About Me & Likes). In my page templates I want to show related posts that have tags in the "About Me" section that match ...
1
vote
1answer
45 views

Display posts in 3 days chunk

I want to display posts from the past 3 days, ordered by meta_value_num. Then when you reach the final page, I want to loop through another 3 days and show those posts. So navigation never ends, the ...
0
votes
1answer
34 views

How to capture a variable query string, then append it to all URLs in a Wordpress site

I have a site in which people will be sent there with various promo code query strings (that will change all the time), i.e., www.example.com/?source=emailad How would I capture the query string, ...
0
votes
0answers
36 views

Way to target parent product category and all sub children

This might be a weird question but I have the following if... statement: if ( is_product_category ( array( 'parent_category', 'child_category', 'child_category', 'child_category ) ) ) { I am ...
0
votes
1answer
30 views

Exclude post on loop by multiple meta key value

I need to exclude the loop two post with different values in your meta key (the same). I investigating got this code that works fine if I enter only one value in value =>. But if I want to enter ...
0
votes
0answers
38 views

Empty 'terms' in 'tax_query' returns an empty array

I would like a simple search on the products page, so I built a custom WP_Query. $args = array( 'post_type' => 'products', 'meta_key' => 'product_price', 'meta_value' ...
1
vote
1answer
64 views

pre_get_posts order by not working

I am using the pre_get_posts hook to alter a query before it runs. The posts in question are performances and so are date and time based. I want to alter the query to get all performances which are ...
0
votes
1answer
44 views

Improving WP_Query for performance when random posts are ordered

I have made a new query after I've asked a question about my query_posts code... you guys didn't find that great, so I decided to change that. I made this: $page = (get_query_var('paged')) ? ...
0
votes
2answers
68 views

Lazy Load using WP_Query pagination

I've been thinking of using WP_Query's pagination to make a custom lazy loading. is there a way to utilize the WP_Query's pagination for a lazy load? Say for example, I have to load 24 posts in the ...
0
votes
2answers
48 views

How to insert variable which contain array value in wp_options table?

I have create a form and i want to store the form data in wp_options table so for that i have created this query $insertquery = $wpdb->query("INSERT INTO `wp_options`(`option_name`,`option_value`) ...
0
votes
2answers
49 views

Check return value of get_posts

I've been trying to change my WP_Query to get_posts methods. But I am not really sure how to check if get_posts is null or have a value. How can i transform this WP_Query checker to appropriate ...
1
vote
0answers
35 views

Using Advanced Custom Field for file upload, how do I load the file url

I'm trying to make a link to the file I uploaded with ACF so that it goes right to the pdf viewer from the Read More link, but I am getting an error here is the code <div class="col-md-6"> ...
0
votes
1answer
51 views

Does wp_query and query_posts affect website performance? [duplicate]

I've been aware about the difference of wp_query and query_posts. I just want to know what impact does both query methods to the performance of the page? Which query method makes the page load quicker ...
1
vote
1answer
28 views

unable to retrive parent page information

I am trying to display the parent page title, parent page id, current title and current id on a page via a plugin. I have the below code which I then echo the value of each. The trouble I am having ...
1
vote
1answer
70 views

Why is my category template ignoring post type?

I am currently working on two sites that make extensive use of custom post types. For both we have a defined number of items (cpts) that fall under a particular bucket (categories). One of the sites ...
1
vote
2answers
35 views

How can i skip same post from taxonomy term?

I'm trying to retrieve the posts of specific taxonomy categories. I have two taxonomy categories. Category One Category Two In these two have some different and same posts. So when i retrieve the ...
1
vote
0answers
21 views

Show all data in database table and make it into an interactive table

I have to make a table where my data from my database can be stored and rearranged with every row. The name of every row should be a link to the function mymanual_edit(). Look at the image for ...
1
vote
1answer
71 views

Why get_posts() not returning only selected category posts from Custom Post Type?

I use widget plugin Getting the random post & URL via ajax. Thanks fischi for help to rewrite functions. Problem is that function returns all posts from CPT, so category select doesn't work. ...
1
vote
1answer
47 views

Change query_posts to WP_Query in page but does not work

I have this code in page.php and it calls the template part for my home. Inside the home.php i used query_posts instead of WP_Query and i wanted to change it into WP_Query. I tried changing it but ...
0
votes
0answers
40 views

WP_Query with meta_query returns where zero expected

I'm using a WP_Query with a meta_query key to get results from a custom post type using the following code: $args = array( 'post_type' => 'werknemers', 'meta_query' => array( ...
0
votes
1answer
49 views

How to user WP_Query to lower the number of queries

I have the following code in the footer (I have removed unnecessary html) which I am trying to optimize. My server is suffocating during the day :) If posts_per_page is set to 1, there are 48 queries ...
0
votes
0answers
26 views

Tried creating a WP_query to add specific post category to page template

I am trying to add a specific post category to a page template but when refreshing my page just spins. Everything looks correct but it seems like my loop is infinitely looping. Can someone take a ...
0
votes
2answers
21 views

WP_Query with child element

I have my calendar events, I want to sort them by creation date with the query, but here's the issue: I have a meta key which has child values: First one is $data = ...
0
votes
2answers
33 views

Custom Theme Building & Permalinks

I am trying to build a custom theme for my wordpress site, I am putting it together from a bootstrap theme I found. This is my first foray into developing with php, and I've just finished learning to ...
-1
votes
1answer
23 views

Show linked products using wp query and woocommerce

Cannot find any information anywhere about pulling the linked products? I need to create a custom query to load the linked products but could only find related. Any information?
0
votes
0answers
45 views

List of CPT posts listed under associated custom taxonomy terms only displays 10 posts per term - how to change/remove limit?

I have some code which displays a list of posts based associated terms like this: Term 1 Post 1 Post 2 Post 3 Term 2 Post 4 Post 5 Post 6 And so on. And it does the job to an extent. A few of ...
0
votes
1answer
73 views

How to get post category list as select in front-end?

I use widget plugin Getting the random post & URL via ajax. I want to add function, that allows users on frontend choose category, and than display random posts from this category. function ...
0
votes
1answer
19 views

Include post_status check within $wpdb query

I've got a function that returns a count from the database for publish posts that match the product ID to the post meta ID (both are the product type). I've realized this query returns unpublished ...
3
votes
1answer
152 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 ...
1
vote
1answer
35 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
39 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
41 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
39 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 ...
1
vote
0answers
41 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 ...
1
vote
1answer
52 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
106 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
22 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
1answer
40 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
55 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
71 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 ...