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
3 views

Woocommerce Get Orders By Meta Value

I have orders, some of them has meta value is set 0. Please see my attachment To filter out orders based on meta value, i am using below code... add_action( 'pre_get_posts', function( $query ) { ...
1
vote
2answers
25 views

Create a custom display order in the main menu

I have main menu which displays two types of links: CPT and Subcategory. I create the menu with a custom request: I retrieve the Custom Post Type then the sub-categories of the main category in ...
0
votes
0answers
13 views

Sort custom post column by generated value?

I have a custom post type with an Advanced Custom Fields repeater field called 'Change requests'. One of the fields within the repeater is 'status'. The field is a select box that can be set to 'New', ...
0
votes
0answers
10 views

Retrieve all custom field values of a specific custom field metakey as an array, inside WP_Query

I'm building a function into a shortcode to retrieve information relative to a custom post. For the most part, I can retrieve everything I need with the following, despite (probably) not being the ...
0
votes
0answers
11 views

How to select post ID for given parent name with nested prepared queries?

I've just started development for the wordpress environment. I am trying to create a prepared statement for the nested query which selects post ID (ID) for the specified parent name (post_parent)? Is ...
1
vote
0answers
19 views

Problem querying Custom post type by custom fields

I have created a custom post type called jugadores in a wordpress site, this custom post type includes custom meta fields for storing custom fields, this include things like the number of the player, ...
0
votes
0answers
4 views

Supless_filter / Wp_query / get_posts / Elementor button / Loop / geotargeting

I have the following problem Got geotargeting and custom post type (Jetengine) I then inserted everything into Elementor that I have a list with the posts with a "Load more" button (where a ...
0
votes
0answers
11 views

Pagination not working wit custom Query

I have created a custom Query that works perfectly with my custom post type, inside this custom post type I'm showing an archive with other custom post types: One is a city, and inside each city there ...
0
votes
0answers
14 views

set transient for wp_query and refresh it after 25 minutes

As I have a auto feed website and I decide to use transient for improving website loading So I have a wp_query and I want to use transient for this query and expire it after 25 minutes ...
0
votes
0answers
23 views

Order is breaking wp_query

Have never encountered anything like this. Running a simple query of custom post types, show only those that the current user is the author, and sort them by a custom meta field. global $current_user;...
0
votes
0answers
10 views

Custom query give me 404 when paginate

in my site I have "CPT Clients" and each client has "CPT Success Stories", also I have a list of client's taxonomies, and when access to one of thees, I need to display the stories ...
0
votes
0answers
10 views

error 404 on pagination when modifying a new wp_query argument 'post_per_page'

I'm using WP_Query to generate an archive custom posts type. In the settings of wordpress I have set to 12 the number of posts to see per page. But on this particular archive page I want to see 6 ...
0
votes
0answers
25 views

WP_Query question: Natural Sort Order for WooCommerce products

I am trying to achieve a natural sort order for the products in our store which have number references such as Nr.1, Nr.2, Nr.13 within the product title but Wordpress/Woocommerce/WP_query whatever ...
0
votes
0answers
11 views

Wordpress pagination sometimes doesn't load/show [closed]

0 I tried to find solution for this, but I can't find anything online and I can't figure it out by myself. So, the problem is, that sometimes native pagination works, sometimes doesn't. I tried to use ...
0
votes
0answers
13 views

Pagination not working on archive.php template?

I have an archive.php template which I only use for the blog. The code goes a bit like this: <?PHP $the_query = new WP_Query( array( 'posts_per_page'=>9, 'post_type'=>'blog', '...
0
votes
0answers
19 views

Wordpress subcategory archive pagination in custom layout

I have blog with categories and sub-categories and use category.php for archive of main category posts, and added a custom layout for subcategory archive layout as subcategory.php (with a function). ...
0
votes
0answers
20 views

Avoid to select/show a randomly queried post for a certain period of time (post of the day)

I would like to present a randomly selected post on my homepage every day. I have already created a working query for this (I have set 60 seconds as time for testing purposes). Now I'm looking for a ...
0
votes
0answers
19 views

Problem with wp_query in Safari

The Query for my custom post type works well for most browsers, but there's a problem loading the images in Safari for MAC (not iphone), the may appear at first sight but they dissapear constantly ...
0
votes
0answers
7 views

How to display category names on the Blog Page(Post Page)

Hi everyone I hope your doing well, I'm having trouble on how to display the category names on the Post Page or my Blog Page, could anyone give me an idea on how to display the category names. Here's ...
0
votes
0answers
6 views

Custom Taxonomy Pagination Not Working

I have a custom taxonomy called by "Singers" related to the posts and Created custom page with the same name (singers.php) as archive to showing taxonomies in there. Now pagination in this ...
1
vote
0answers
16 views

Meta_query with multiple keys and multiple values

I have a WP Query code like below to check if have post match all post_meta > get that post, else create new post, but the result always show me a post have only loaicua = cua-chinh and loaiphong = ...
1
vote
1answer
16 views

Fetch posts that match term slug first two letters (wp query)

I want to fetch all posts whos terms matched the first two letters of the search letters. For example, I have terms 8027179, 8027180, 8247180. Now I want to assign letter 80 and fetch posts attached ...
0
votes
0answers
13 views

Filtering posts based on three taxonomies

I've built a filterable post listing where the user can filter based on two taxonomies, this is working but I now want to add a third taxonomy to the filter, but I think the logic I'm using isn't very ...
0
votes
1answer
32 views

Different options per post type in WP_Query

I have two post types (type-A and type-B) and two taxonomies (tax-1 and tax-2), both assigned to each post type. This means that posts from type-A can contain terms from tax-1 and tax-2 and posts from ...
0
votes
0answers
13 views

WordPress Sub Category Archive, Show Extra Empty Page Number in Pagination

This my code for sub category archive page: <?php // the query $the_query = new WP_Query(array( 'category__and' => array( 2 ), ...
0
votes
0answers
14 views

Save large WP_Query to transient === false

I try to save a WP_Query to a transient but it's always comes back false dispite the fact that the transient is saved. Here is the code: $fitsToTransientName = 'g_wc_fits_to_' . get_the_ID(); $...
0
votes
1answer
10 views

build child and anchestor three from post parent

I'm trying to build a three menu from a custom post type, and wanna build a complet three from the posts children and parents, with all levels both up and down included. And actually the function ...
1
vote
0answers
12 views

Show Post Count of a Category

I've been stuck on this for a little while now, and have tried multiple ways to achieve this with no luck. I've been looking for two ways to display the total posts found on a specific, and non-...
1
vote
1answer
28 views

WP_Query Filtred by author name ( Return null )

I want to list all pages whose author has a specific name but WordPress returns null values $args = array( 'author_name '=> 'admin', 'post_type'=>'page' ); $pages = new WP_Query( $args )...
0
votes
0answers
36 views

How to display only the parent owner of an attachment pdf file (using AC and ElasticPress)

I have a CPT (using ACF fields), that have a title, some other taxonomies, and a pdf attached file (it's also an attachment file because I need that Elasticpress search in it). When I do a search, ...
1
vote
1answer
29 views

Trouble with wp_reset_postdata() in Admin Panel

I'm hooking into 'edit_form_after_editor' add_action('edit_form_after_editor', 'make_the_button_to_generate_a_report_number'); function make_the_button_to_generate_a_report_number($post) { Check that ...
0
votes
1answer
11 views

WP_Query breaking the loop in a nested loop

I'm not able to figure out the solution for the following code. When I remove the query section, the location loops but with the code, only one result of location (parent loop) is displayed. if (...
0
votes
0answers
11 views

“Post List” Loop containing other “Child Post List” loops causes pagination error ELEMENTOR

I am using a loop template to display posts in a custom template. The loop template contains another loop to display a list child posts. Child post list requires paginaion, but I am encountering a bug ...
0
votes
1answer
82 views

Custom WP query with polylang term

i am banging my head on how should the mysql query be correctly defined. I have term_taxonomy_id id defined for polylang languages 2 and 9 I want to return ONLY return posts, who has term_taxonomy_id ...
0
votes
0answers
13 views

Can i get a value from a radio buttons group inside a html form field using Elementor Pro actions after submit?

I have a form created with Elementor, and i have to create a specific design (pricing plans) with radio buttons, so i have added an html field on which i wrote an shortcode. This shortcode will load ...
0
votes
1answer
32 views

Fatal error: Uncaught Error: Cannot use object of type WP_Error as array in /../plugins/rm-payment.php

I using remote payment system of 2 WordPress site, 1st WordPress site to 2nd WordPress site. 1st is main website & 2nd website work like merchant website that process payment of paypal. We fetch ...
0
votes
1answer
24 views

Wordpress has a list of reserved words, can I override them, to use one in a query string?

I want to use blah.com/myscript/?year=2020 But this causes a 404 (and yet the page loads). However, it seems as though trying to serve a download is borked, because of the year parameter. Is there a ...
0
votes
0answers
16 views

WordPress WP_Query make mysql time out

I got a problem that I install XAMPP on my computer to develop,and recently I want to use WordPress to expand two functions: 1.posts pinned and deadline is required (the post will not pinned when time ...
0
votes
0answers
12 views

previous_posts_link & next_posts_link doesn't generate any output

Hey I am using a WPQuery to loop through and show blog categories in posts. It's in a page tempplate. has 21 posts and I want them to show 10 per page with navigation links for next pages of 10 posts ...
0
votes
1answer
22 views

ACF: How can I publish values of ACF fields in a loop while using wp_query?

I'm using ACF to add fields to a custom post type. I've created an instance of WP_Query to set up a loop. Within the loop I can publish the standard fields using the_title() and the_content(). However,...
0
votes
1answer
12 views

3 posts from each existing category on one page

The following is not working... <?php $categories = get_categories( array( 'orderby' => 'name', 'parent' => 0 ) ); foreach($categories as $category): $args = array( 'cat' => ...
0
votes
0answers
13 views

I want to display parent and child posts in a lists

I need display custom post type posts list same as menu till n level. Below is the flow chart how I need to display. Post 1 Child Post 1 Child Post 1 Post 2 Child Post 2(A) Child Post 2(A) ...
0
votes
0answers
15 views

Wordpress primitive query returns = array

i am trying to primitive query form this wp_query: $query_v = array( 'post_type' => array('pro'), 'posts_per_page' => -1, 'orderby' => $count_visit, 'order' => 'ASC', ...
0
votes
0answers
11 views

Catalog page filter by through url?

I am trying to get some custom parameters in the catalog page (archive.php) query. Like I can filter with attributes. For example, this works with the built in filter products by attribute woocommerce ...
2
votes
1answer
51 views

Having trouble with custom date field for CPT query (Wordpress)

I've read as many of the questions and answers on here as I can find and none of the solutions are working for me. No idea what I'm doing wrong here. I have a CPT 'event' with meta key 'start_date' - ...
0
votes
1answer
12 views

Displaying all posts from other sites on the network on one site

I have a multi-site setup as follows Main Site has no posts Site A has 1 post A Site B has 1 post B Site C has 1 post C What I'm interested in is to be able to treat the main site as an aggregation ...
0
votes
1answer
17 views

How to display all posts not in a post_format

Using WP_Query() I want to display all posts -except- those with the 'image' post_format. I tried this, but it did not work. $args = array( 'relation' => 'NOT', 'tax_query' =&...
0
votes
0answers
12 views

Wordpress Query for CPT that only shows posts within radius of current user's geolocation

I have a CPT called medical_providers. Each medical provider has two ACF meta_fields (latitude and longitude). I want to write a wp_query to only show medical providers that are within a certain range ...
0
votes
1answer
28 views

Sort by price wpdb

I have a page on my wordpress to search for tires everything works fine but I would have liked to know how to add an extra column to sort them also by price. They can already be sorted by size and ...
0
votes
0answers
12 views

Order category in shop page

i have this function to order for category the shop page in woocomerce function so_27975262_product_query( $q ){ //$q->set( 'category__in', array(96,105,97) ); if( !is_product_category() ) { ...

1
2 3 4 5
104