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
-1
votes
0answers
12 views

How to add space between posts within the loop

<div class="col-md-6"> <!-- Search Form --> <div class="search-form"> <div class="input-group mb-3"> ...
0
votes
2answers
14 views

get_the_ID() doesnt work

Here is my query loop: <?php $query = new \WP_Query( $args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); ?> I want to call $post ...
0
votes
1answer
11 views

WP_Query not returning custom post type

I'm using the below code to try to return the count of custom post types but the query isn't finding anything. I change the post_type to project and it works fine. This is also being used outside of ...
0
votes
0answers
13 views

Display custom posts and their childs hierarchicaly

I am working on a support manual. I created a custom post type 'manual' and I want to display an automatic menu of the posts and their childs. It would look like this: Post 1 Post 2 Child post ...
0
votes
1answer
12 views

On what hook can I get the queried object's final state?

My goal here is to create a mini-plugin that allows me to create social share links, as such, I am very, very interested in getting the most up-to-date version of a queried object's link/title. I've ...
1
vote
2answers
18 views

Bypass “supress_filters” in WP Query

Apparently, for some illogical reason, the developers decided that the only way to fetch posts in all languages, is to add supress_filters=true to the WP_Query (instead of having like say, a ...
0
votes
2answers
21 views

What code to use in an array to call the current sub-category?

On a page like taxonomy-product_cat.php - this function lists just the products for the called sub-category - bags: $args = array( 'post_type' => 'product', 'product_cat' => 'bags') $loop = new ...
0
votes
1answer
34 views

Change AJAX filter from POST to GET for URL Parameters

I have a well defined AJAX filter, in two parts, one for a load more button, and one for a selection of drop down filters. Both reload a list of properties on the front-end in AJAX, and work together ...
0
votes
1answer
11 views

Custom order revolution sliders post base slides as inserted in Specific Posts List field

My homepage shows about 10-20 post that are manually selected in a slide. I have used Revolution slider. There is a field Specific Posts List field Where I have inserted post Ids 16427,16557,16822,...
0
votes
1answer
22 views

Trying to get pagination working on WP_Query() post grid

So I've been developing my own theme as a learning experience, and I'm at a loss regarding how to get pagination working. I've tried several things before getting to this point and asking, I just seem ...
0
votes
0answers
6 views

Select all sites from WPMU by user, ordered excluting some fields

I want to select all sites from current user in multisite, but ordered DESC, excluding the main site (id = 1) and including these, that are public (with public setting in the result). I know for - ...
1
vote
1answer
26 views

Wordpress Related Post by tags in Single.php

I want to create a related post, but the code I tried shows only related post using only the first tag. I want related post which use all tags. (Because my site is a blog and each post can have up to ...
0
votes
1answer
18 views

Accessing post's meta data based on user's click of a post

I am displaying a gallery of custom post types. When the user clicks a post, instead of redirecting to a single template, I want it to redirect to another page (too easy just change the link since all ...
0
votes
1answer
24 views

WP_Query of custom post type sorted by meta_key has unexpected results

I do not understand why my code outputs the events in a seemingly random order. It's not sorting by the start_time as I would expect. <?php $args = array( 'post_type' => '...
0
votes
1answer
25 views

Move some posts to end of sort order, even if there is a sort in the wp_Query already

I have a site that lists properties for sale. I have a custom wp_query, with a sort dropdown I created. This dropdown reorders the posts query by date, price (low-high & high-low) and beds (low-...
0
votes
0answers
20 views

How to display custom search results from a selected category of a custom post type?

I have a website that has a blog and a custom post type called proyecto. They are on mywebpage.com/blog and mywebpage.com/portafolio.Each of those pages have a search field and category dropdown ...
0
votes
1answer
19 views

Use WP_query to match post types based on custom field values

i'm trying to query posts from the post type Product that match with the current post in the loop from the post type Item, based on the custom fields product-ean and item-ean. For example: i have a ...
0
votes
2answers
16 views

How select query is generated in a Custom Post Type?

I have this table that is generated in a Custom Post Type (CPT) Is there an option that I can modify the query? For example, I have this post_type = 'my-type' in wp_posts table. I want to do a JOIN ...
1
vote
0answers
16 views

Anyway to grab author name and featured image in an embeded in inital array of posts outside of loop?

Here's how I'm doing it atm. $query_vars['paged'] = $_GET['page']; $query_vars['posts_per_page'] = $_GET['posts_per_page']; $query_vars['post_status'] = 'publish'; $query = new WP_Query( $query_vars ...
0
votes
0answers
10 views

Filtering get_terms loop by custom fields & custom taxonomy

On specific page I’m displaying posts from my CPT („opencourses”). Posts from this specific CPT are grouped by custom taxonomy („kategoria”) - this piece of code works. At the same page I have four ...
0
votes
1answer
33 views

Custom WordPress post query for displaying time-released content on website

I am trying to implement a "content drip-style/time released content" subscription system using a WordPress query that filters and selects content from a custom post type using set parameters and ...
0
votes
1answer
23 views

Custom query for certain post type OR another post type with a certain category

I want to display posts that are either EITHER Post Type A OR Post Type B but ONLY if they are also in CATEGORY 1 Is that at all posible? How do I built my custom query?
0
votes
1answer
16 views

1500+ duplicate queries via get_option function (query monitor)

I'm having a huge performance issue once I'm logged into Wordpress. Query Monitor says it's doing over 1500+ duplicated queries with the get_option function executing this query: SELECT option_name, ...
0
votes
1answer
16 views

WP Query search for attachments and their exact title

Due to lack of reputation, I must now ask the question. I want to create a search for all images in the media libary. The search result should only appear if you search for the exact title of the ...
0
votes
1answer
15 views

how to handle multiple ajax wordpress queries?

I am having a problem with two ajax action. I have a post grid it has a frontend sorting "ASC" and "DESC". So if I click on "DESC" it changes the WordPress query arg "order by" to "DESC". It works. ...
0
votes
0answers
36 views

Trying to display related custom posts only in same child taxonomy as current custom post

I have some custom post types 'home' and 'provider' that share a custom taxonomy 'states'. The taxonomy is hierarchical so Georgia is a parent of Atlanta etc. In the single template for the post type '...
0
votes
0answers
8 views

Query BETWEEN timestamps (today and in a custom field)

I am using wordpress 5.3.2 and advanced custom fields pro Version 5.8.7. My custom field is called timestamp. See below my ACF configuration: I tried to query the db like the following: ...
0
votes
1answer
22 views

Foreach-generated custom tax queries, each with an ajax “Load more” button

I'm looping through custom taxonomy terms to create a WP_Query for each term, then displaying the posts on the front-end. I'm also attempting to adapt this helpful tutorial(and accompanying comments) ...
0
votes
0answers
14 views

Get categories within specific term

I have a WooCommerce shop, where I'd like to show every possible product category, where the products have a specific attribute (term). Say I have a product attribute called: "Designer", then I wish ...
0
votes
1answer
25 views

400 Bad Request, in wordpress theme development, wp_ajax

As Salamu Alaikum, I am developing a theme and I have tried every way of getting a successful ajax request and it is still showing me the 400 bad request error. And there is no solution I found going ...
0
votes
0answers
10 views

WooCommerce Product Table - filter query on attributes

I am using the Barn2 Product Table plugin with WooCommerce. I would like to modify the main query so that only products with a certain attribute are displayed (depending on the logged in user) I am ...
0
votes
0answers
32 views

Filter posts by their related field's custom field

I have two post types named 'programs' and 'universities', where the programs are connected to their respective universities. I want to filter programs by university's custom fields such as ranking ...
0
votes
3answers
71 views

Display all custom meta field values from the database using ACF Repeater

I'm working on a personal project which includes multiple custom fields (created via ACF). A few of them are repeater types. I want to to display 3 arrays/blocks of those repeater subfield values. ...
0
votes
1answer
26 views

Related categories order posts by category

How do I order following custom posts by category like so: Cat title player 1 player 2 Cat title 2 Player 5 player 7 As far to the code below is where my knowledge goes so any advise is very ...
1
vote
1answer
13 views

Import wp users via one click demo option

I have created a WordPress theme and added an option to import demo data in which I have added WordPress posts, pages, customize options. when my client buy the theme and use one-click demo option to ...
1
vote
1answer
26 views

Need wp_query to return all children and grandchildren

I am working on a site with three different main 'topevel' sections, that act as the top level parents of the site. Each toplevel section has children and grandchildren, and there needs to be a ...
4
votes
2answers
59 views

How to get random posts and order them by date

I need to get some random posts and order them by date. To get random posts I used the following: $query = new WP_Query( [ 'post__in' => $post_id_array, 'posts_per_page' => $...
1
vote
1answer
22 views

Display CPT posts based on specific taxonomy

So I have a custom post type called opencourses. There is a custom taxonomy called typ. Obviously inside I have a multiple terms divided into two main pillars (production and services). ...
1
vote
1answer
37 views

Wordpress pagination not working using WP_Query

Ok I know there are a lot posts on this already but I'm not able to find what is wrong with my code. Because pagination is still not working. The weird thing is the same code and template works fine ...
1
vote
0answers
51 views

meta_query BETWEEN, but the range is stored in the custom field

I've seen plenty of samples of using meta_query to find if the value is between a range, where the range looks something like this: $meta_query_args = [ 'key' => "custom_field", 'value' =...
1
vote
1answer
35 views

WP_Query tax query part of slug

I have problem with filtering post with tax query. I have a custom taxonomy called 'actors' and example of the slug is 'david-hasselhoff'. The problem is the post is found when I search with 'david ...
1
vote
0answers
20 views

WP_Query search posts by custom post type and custom taxonomy

I have custom posts articles with custom taxonomy tags-articles, I need search all posts with have the term in title, or taxonomy associated with same title (or partial title): Example os published ...
2
votes
1answer
35 views

How to add another parameters to WP_Query?

I need to do something like that: $postsOrder = get_sub_field('posts-ordering'); if ($postsOrder = 'post_views_count') { $queryPopular = array ( 'meta_key'...
0
votes
0answers
17 views

Meta_query on same meta key, with diffrenct values

i'm trying to get_users with the meta_query where i need to find users where either they don't have the meta key, or it is blank. It seems like everywhere i look, i should be able to use the OR on ...
0
votes
0answers
24 views

wp query search multi terms

i have this code it work perfect if i search for 1 term but when i add 2 terms to search it fail protected function process_item ( $data ) { try { $data = array_map ( 'trim', $data ); ...
1
vote
1answer
26 views

problem by deleting new plugin installed inside the WordPress after any heroku app sleeping [closed]

I have installed this repo inside my Heroku app as you can see here: https://ss-wp25856.herokuapp.com By user id: ss and password (for more information to check or log needed): n6RF1TSNrNkA!%...
1
vote
0answers
26 views

Should unaltered default loop/query return a list of custom posts belonging to a custom taxonomy?

Short version: I am wondering if the default WP loop (for example in a rather simple index.php) is supposed to return custom posts belonging to a custom taxonomy when the URL is something like https://...
1
vote
1answer
20 views

Function get_queried_object() return NULL in custom taxonomy

Hi i need get term ID from custom taxonomy but it is always NULL. taxonomy-galerie-kategorie.php <?php /** * A custom taxonomy template for gallery. */ ?> <?php ...
1
vote
1answer
22 views

How to restrict the search fields for a specific post type

How can I restrict the search for a specific post type? I am using the following code in functions.php: function searchfilter($query) { if ( is_admin() || ! $query->is_main_query() ){return;}...
1
vote
0answers
20 views

How to verify wp user password by sql query in wp? [closed]

I want to verify the user password without function only by the SQL query.