Questions tagged [wp-query]

"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 global variable that holds the main query object prepared by WordPress based on a given request.

Filter by
Sorted by
Tagged with
0
votes
0answers
48 views

Slow page loads due to WordPress Core Query

I have a page with many posts and every single page load is noticably slow. Hence, I have checked with Query Monitor the culprit(s) for the slow loading time and found that one query in particular is ...
0
votes
1answer
37 views

How to create page with post content in it?

I have a page that I would like users to remain on. It is like a reference guide. Hence I would like to load post content into the page without the header / sidebar etc. Just the post content. ...
0
votes
1answer
46 views

Finding post ID dynamically on click

Goal: I'm making a portfolio website in Wordpress. It's the first time that I have setup a Wordpress page by myself (I have done on internship but those were template-ish). I have seen this website ...
0
votes
1answer
86 views

How to display upcoming events by dat with Modern Events Calendar Lite

I'm using the plugin Modern Events Calendar Lite. This is a recent plugin, so actually no doc exist. So i'm looking a way to display my upcoming events on homepage. But i can not make it to work, ...
1
vote
1answer
42 views

How do I use `posts_distinct` correctly?

I've scoured the interwebs but can't find a good working example or discussion of the filter posts_distinct I'm using Advanced Custom Fields but I don't think that could be the problem. Anyway, ...
0
votes
1answer
53 views

How to use jQuery validation to set the search bar to accept only a specific input?

I'm new to the wordpress world. As a starter theme I was suggested to use the basic one given by underscores.me. The search bar is fundamental for my site, so I would like to customize it in order to ...
0
votes
0answers
23 views

Wp-query output correct, but the loop shows one less item (only sometimes)

My site is making a strange bug, the code below works 99% of the times but every now and then it return only 2 items in the loop, even that the query results have more products // get the cats this ...
0
votes
1answer
11 views

Access Wordpress query by index number outside the loop

In wordpress query, Can I single out the specific post by index number of the query result? for example <?php $args = array( 'post_type' => 'headimages', ...
0
votes
1answer
18 views

paginate_links method doesn't show second page of my custom wp_query

I'm trying to create a custom search page using wp_query. I'm using post method to get search values. At first, the search was doing fine, but when i got a search results of more than 4 posts (i set 4 ...
0
votes
1answer
25 views

WP Query with meta queries

I have the following WP_Query: $query = new WP_Query(array( 'post_type' => 'some_cpt', 'posts_per_page' => -1, 'meta_key' => 'active', 'meta_value' => 1, '...
0
votes
1answer
25 views

Unusual high query of user meta data

We have a WordPress installation with many plugins installed. The site is not that highly frequented (maybe 10-20 concurrent users). I know the amount of plugins comes at a cost of performance. ...
1
vote
1answer
69 views

Change default ordering of taxonomy terms - pre_get_terms

I wanted to change the default taxonomy terms order by its 'term_order' value instead of 'name' in admin side. So I tried something like below. But it doesn't work and php memory exhaust. function ...
0
votes
1answer
31 views

Exclude parent categories from recent posts list

I want to show only the sub-categories from a post's specific parent category and exclude all the other categories. This is for a loop of recent posts on my front-page.php. Each recent post is ...
0
votes
0answers
11 views

sql query page listing with option selected

I want to separate a page page from the sql query. for example current page and last page with option selected. my listing page code <ul class="list-group"> <h2 class="h3">...
0
votes
0answers
31 views

Woocommerce featured products query no longer working

I have a query that's stopped working since Woo 3.6 upgrade I think. I'm trying to get products in a category that are featured. Any help would be much appreciated:) <?php ...
0
votes
1answer
26 views

Query string form $_GET['value'] is not working as meta value in wp_query

Here is my code.How strange! if I put any static value replacing $s_string, it's working fine. Thanks in advance for any help. $s_string = !empty($_GET['q']) ? sanitize_text_field($_GET['q']) : ''; $...
0
votes
0answers
31 views

Not expected result with multiple search terms in wp_query

I have WooCommerce installed and I'm trying to find products with size "60x60". Sometimes in title were used normal x symbol and sometimes it's a cyrillic х. Now i'm trying to find all products with ...
0
votes
0answers
45 views

Wp_Query Post per page not working?

I have specified the post per page to be 3 as arg but it does not seems to work, all the post are being shown up. Not sure why i works if i enable no paging false but pagination shows up. Array ( ...
0
votes
0answers
23 views

What does wp query caching parameters do?

if i set 'cache_results' => false whether caching will be ignored? Say if I am using popular plugins like w3 Cache, WP Super Cache. if order by rand is used then caching can create issues I think. ...
0
votes
0answers
22 views

Require_once failed to open stream WordPress

I've been trying to create a small plugin to do some basic tasks on my website. I created the plugin which was initially working fine, I made no changes and for some reason it no longer works. Here ...
0
votes
0answers
33 views

Order Element By Custom Field in Wordpress

I'm working on wordpress and I want to order my post by rating. I'm new with it, and I need some help. I tried many things, but seem it's not working :/ My Wordpress Custom field which contain the ...
0
votes
1answer
47 views

add action for wordpress query at a specific position

I wanted to allow users to put custom code to placed in between the wordpress query. say If I create a post query I want display an image in between--eg after 2nd, or after 5th post. is it possible to ...
0
votes
0answers
26 views

Getting custom field dynamically from variable

I feel like this should be relatively easy but for some reason I'm lost. I'm trying to access an associated posts ACF repeater field based on what row is being outputted. Here's the query in ...
3
votes
1answer
38 views

Initiating WP_Query() with no args and adding them later through the query() method

I've inherited maintenance of a theme from another developer, and I'm trying to understand if there's a good reason why they did this. The theme includes a page template that runs a custom query for ...
0
votes
1answer
26 views

Adding Multiple Post Types to Query [duplicate]

I'm trying to add a 'Lessons' post type to populate the wp-query as well as the pre-existing post type 'Modules. Preferably I would like them to be combined into one query showing the most recent 6 ...
0
votes
1answer
32 views

Filtering posts by archive showing all years

I have set up a WP_Query within my archive.php page. This is so I can do different things such as pagination etc. I also have two drop down filters categories and archive (yearly). When selecting a ...
0
votes
0answers
21 views

Group By in a Metaquery

I would like to add a group by in a meta Query. The current generated query is as follows: SELECT SQL_CALC_FOUND_ROWS wp_posts.post_title, wp_postmeta.meta_value, mt2.meta_value FROM wp_posts ...
0
votes
1answer
21 views

Display All Top Child Categories / Taxonomy

I want to display the top 10 child taxonomies, no parent. This code gets 1 top parent taxonomy, then only displays it's 10 children. I would like to grab top 10 child taxonomies of all parents of ...
0
votes
1answer
72 views

How to combine two WP_Query objects?

I need to combine two different WordPress WP_Query Objects with separate $posts_per_page lets say we have two different categories and each of them is responsible to show 18 posts or products of their ...
0
votes
1answer
110 views

Hide products in uncategorized category from search results

I have about 20000 products and I am using electro theme. All of them belong to uncategorized category (id: 979) and most of them belong to other categories also. I want to hide from the search result ...
0
votes
0answers
37 views

how to get custom attachment url?

Is there a common method to get a custom attachment URL regardless of the plugin or custom code used? Say if I use ACF plugin I can create an image field and get the url with get_field('fieldname'); ...
0
votes
1answer
15 views

Wp-query and column blocks

Maybe this is asking too much, but the new blocks give a simple way to add columns that work well responsively. ie you can just drop image thumbs into column blocks and they work perfectly on mobile ...
0
votes
1answer
58 views

Wordpress Carousel with recive posts (Bootstrap)

I have a problem I would like to create a slide show based on Bootstrap, and I found a few different solutions, but none work, despite trying to fix myself but failed, I do not know if the problem is ...
2
votes
2answers
232 views

Query WooCommerce orders where meta data does not exist

I'm trying to fetch all my WooCommerce orders where some additional metadata is equal to not empty. $orders = wc_get_orders( array( 'orderby' => 'date', 'order' => 'DESC', '...
1
vote
1answer
192 views

How to get the WC_Product Object when using a WP_Query in WooCommerce

I am trying to list my products using WP_Query. I have used a query such as the following one: $slider_products_q = new WP_Query([ 'posts_per_page' => 8, 'post__in' => $...
2
votes
2answers
50 views

Meta-value query

A little long-winded but trying to explain clearly :) I am delving into the code of my new theme and am not familiar with this type of data storing/pulling - can someone help me understand what is ...
0
votes
0answers
10 views

Substitute post with certain meta key in loop

I have some logic where a post can be a link to another object. And if it outputted on frontend linked post should be shown, not original. Now I have the following code in my template: $is_list_link =...
0
votes
0answers
21 views

Woocommerce - Order categories and then pull products by that order

I will give an example what I am trying to make. I have 1 parent and 2 child categories - Sport > Football & Basketball. Also there are 2 custom taxonomy terms (Brands) - Nike & Adidas. Now, ...
0
votes
1answer
209 views

WP_QUERY with group by with custom fields

I need to use group by in my posts with a custom field "eventMonth" that will have values like "April-2019" - "June-2019".. (I never used the wp_query with a meta_query data so...). I've the next ...
-1
votes
1answer
26 views

WP_Query and DES sort for Custom Taxonomy based upon a meta field?

Is it possible to filter events (WP Query) within a Custom Taxonomy archive by ‘Start Dates’? I create a Custom Post Type called “Events” and in that “Events” is a Start Date When I view Custom ...
1
vote
1answer
88 views

Show only one post on custom post type archive

First of all thanks for your time! Im trying to show only the last element of my Custom post type (CPT) in the archive page, I tried it but it is showing the las Post, not the last CPT element, I ...
0
votes
0answers
18 views

How to create list of categories and get post page

I have a list of categories page, and i want if i clicked on the category it will take me to list of post that using the category. I know this confusing, but i give example sitemap Parent Category 1 ...
0
votes
1answer
24 views

WP_Query based on another query on the page

I have a query that checks for a custom field set on that page and then creates a carousel to loop them with a background image. What I then want to do, is query a post type that uses a custom ...
0
votes
1answer
32 views

Query post by Category and custom file (ACF)

Well, I try to create a query that will only take posts if the conditions are met, Must be in this category (Event) and have the selected type (News-checkbox). First I asked on the ACF forum but the ...
0
votes
0answers
33 views

Custom query showing all acf field values instead of the one searched

add_action('wp_footer', 'ajax_fetch'); function ajax_fetch() { ?> <script type="text/javascript"> function fetch() { jQuery.ajax({ url: '<?php echo admin_url('admin-...
1
vote
2answers
23 views

How to fetch only current hour posts?

How can I fetch the post which is posted only this hour? Example: It's 9:00 am here I want to show all the post that is posted within 9:00am to 10am and it will check all the hours in same way.
0
votes
1answer
32 views

Query where ANDing slug values not working

I realize this isn't the most elegant sql. I modified this query where the original query only selected from a single category (the slug field of the terms table). I am trying to obtain a result set ...
1
vote
0answers
37 views

Taxonomy Query Relation field not behaving correctly?

This is my post entries with categories and tags I am using Taxonomy query When I use relation AND - Tax Query for Category Geed + Tag Cool Nothing shows up. But When I use relation OR 2 The post ...
-1
votes
1answer
20 views

Help with showing text when something is entered in my search bar

I'm having troubles replacing text when there is something entered in the search form. As you can see in the image below i want to replace 'mijn gemeente' with the get_search_query text if i'm ...
0
votes
2answers
33 views

Why in my query is display two title?

I have a quite specific problem, I created a query that currently has to display the first post differently from the rest and everything seemed to work, but there is a problem that displays the title ...