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

WP_Query on meta returns featured posts (not matching meta query)

Migrating a site to wordpress wanted to redirect old urls so I made a function that would catch 404, look for a meta value that would match the number in the url to then redirect. It worked like a ...
0
votes
0answers
13 views

Display products with unique attribute value on product archive page woocommerce

We have 40000+ products on our site and have a custom product archive page for manufacturers. Each product per manufacturer has an attribute 'pa_series' that they belong to. Some series have 100's of ...
0
votes
0answers
10 views

Unable to correctly $counter for Pagination

I have a page that displays posts by category: https://www.worldwideholidaysclub.com/holidays/ But, I want to have different pages for the main tags in order to promote the pages separately. My ...
0
votes
1answer
19 views

Merge two search functions for custom post type

In addition to the site-wise search. I have a custom search for a certain post type and with different ordering than the global search. Here are the two function, which works. I wonder if those two ...
0
votes
1answer
25 views

Numbered Pagination Showing The Same Posts After Altering WP_Query

I think the title sums the problem up, but I'll explain more with the code below. As you can see, I'm trying to start the loop from the second latest post for some theme reasons which forced me to ...
0
votes
0answers
13 views

alter the main query on 404 error page to display content from another page

I have a normal page with content that can be maintained by editors via the backend. Now I want to display this content on the 404 page. So i tried to use the pre_get_posts hook to alter the main ...
0
votes
1answer
23 views

use mysql variable in a $wpdb->query to reindex a column?

I have this MySQL query, which do work in PHPMyAdmin: set @ROW = 0;UPDATE `wp_wpsstm_subtracks` SET `subtrack_order` = @ROW := @ROW+1 WHERE tracklist_id='176226' ORDER BY `subtrack_time` ASC I would ...
0
votes
2answers
13 views

Query posts with “non set” meta value

I'd like to make a query of custom posts based on a custom field, say instrument. I need to be able to query only those posts for which the custom field has not been set (i.e. for which the meta value ...
0
votes
0answers
21 views

Sort posts numerically by converted date format

Updated for clarity: I need to convert the post date format from Y-m-d to mdY and sort by mdY numerically, not by the actual timestamp. My goal is to order the posts by month first, then day, then ...
0
votes
0answers
9 views

Where my home page and font options has gone?

I accidentally deleted my home page. I have a customed theme. I hit restore page from trash yet still a different new page exists as my home page. I searched my pages and I see a different page ...
0
votes
0answers
9 views

Sorting posts By Taxonomy using 'post_clause' filter

I have a table list in my plugin's admin panel that has taxonomy columns. I'm trying to add some sorting functionality for those columns and I'm using the post_clause filter to alter the query to ...
0
votes
1answer
24 views

How to get meta key list efficiently?

I have this function to get the meta keys for all the post types. public function pgggo_custom_post_type_keylist() { //gets the list of post types $...
0
votes
1answer
13 views

How to show specify category template for both parent and child category

I tried to create a category template apply for parent and child specify category. I has create a file name 'category-1.php , in this file I used the loop for get the list of post: <?php if (...
0
votes
2answers
15 views

how to pass args for archive.php query?

I am trying to pass args to archive.php so that I can order the posts, set the number of posts, etc.. but the query is done like this <?php if (have_posts()): ?> <?php while (have_posts())...
0
votes
1answer
20 views

How to get the latest post list (of the parent custom custom type)

I am looking for a solution to get the latest list of custom parent posts. example: Post A Child Post A Child Post B Child Post C The bold list items are the posts/pages I want to retrieve. I ...
0
votes
1answer
36 views

Select multiple categories with is_tax

i have a good function for exclude out of stock products from category. The problem is i want exclude for more than one category (really i want show only in one category, but i think this is the way. ...
0
votes
0answers
25 views

how to retrieve specific product attribute value in an sql query?

I am looking for some suggestion on how to run a query on wp-term with multiple "same column name as different attribute name" bottom line I am trying to query woocommerce products + all their ...
0
votes
1answer
29 views

Query custom post type and custom field by URL parameters

I have a custom post type staff. and a custom field alphabet for posts in that post type. Each staff will be assigned to a letter either A or B ... Z based on the first letter of the staff's name. On ...
0
votes
0answers
47 views

Post Type Search Gives Unexpected Results

I am working on a WordPress site that has several custom post types. Of course this lends itself to writing a custom search form. However, the results from test searches have been less than ...
0
votes
2answers
17 views

How to get only present and past posts with post_date

An administrator wants to make posts for a future date but not visible for visitors. The posts come from a custom WP_Query inside my plugin so the basical WP behaviour does not work in this case. I ...
0
votes
0answers
14 views

How to get user avatar via WPDB

For my REST-API i need to get for every post the username, date ... and Avatar ! $query ="SELECT POST.ID, POST.post_title, POST.post_date, USER.user_nicename FROM wp0x_posts POST INNER JOIN ...
0
votes
0answers
15 views

match and update acf fields with array values

i created array from gravity forms entries that has information about students payment. this array contains only the values i need about payments. $arr: [6047] => Array ( [0] ...
1
vote
1answer
20 views

WP_Query To call data from diffrent tables

I need to retrieve data from multiple tables , wp_postmeta to get posts with a specific type ( question ) , wp_user for author informations and also wp_comments . I need those information to use them ...
0
votes
0answers
14 views

WP query custom search by meta query nested ACF repetear field Group > Repeater

So I have searched the web but didn't found quite an good solution to this problem. I am having nested ACF field with a repeater inside a group and I want to display and order wp query by that item ...
1
vote
0answers
12 views

Wordpress custom post type with meta - how to retrieve with wp_query

I developed simple plugin and now would like to get only posts where start_date < $now & end_date > $now so I have to add meta_query to the args but how should it look like? $args = ...
1
vote
1answer
14 views

Get a list of posts with associated meta_value

Recently I began to use the Custom Fields. I would like to display a listing of posts which contains the meta_key "oldtimer" and also get the corresponding meta_value. Here is the expected result: &...
0
votes
0answers
11 views

One of two similar WP Query is very slow

I have two WP Query are very similar. one is fast and another is very very slow. I have already test two query via mysql directly. the fast one: SELECT wp_posts.* FROM wp_posts INNER JOIN ...
0
votes
0answers
8 views

in WordPress Loop update_user_ meta with Current Month and Year as Meta_Ley

I am making a page for my wordpress authors to see there stats. For the same, i first loop through all author ids, then i loop through all of there posts, and sum the post views meta key for all. I ...
0
votes
1answer
38 views

unique post in “$args” of wp_query display more than one post

I can't find the rights arguments to display only one post of a category when I click on a div. I call the post with Ajax and I display it in a div popup.Perhaps these arguments are not sufficient, or ...
0
votes
1answer
20 views

WP_Query to display number of custom post type filtered (order by) taxonomy

I am trying to display the number of posts made in custom post type "incidents" by the custom taxonomy "store". eg. Store 1: 8 posts Store 2: 6 posts etc. I have been looking through here and ...
0
votes
0answers
12 views

AND relation in tax_query now working

I want to apply filters on 'retailers' custom post type. Filters are on the basis on following taxonomies. Shipping Type Release Type Raffles I am using AJAX to apply filters. (https://savior.d....
0
votes
1answer
24 views

Hide posts if user is added to it WP_query

I have this list of posts in wordpress. I've made a favorite function that when you mark something as favorite it gets added to the front of the line. The issue here is I run this 2 place. One top ...
0
votes
3answers
32 views

Getting posts by custom field value

I need to get posts with a price less than or equal to for example '1000'. The price is set in an arbitrary custom field. Trying to posts a price that is less than or equal to 1000 $posts = new ...
0
votes
0answers
9 views

Woocommerce sorting not working properly after adding 'woocommerce_product_query' hook and editing the post__not_in or post__in query parameters

So I have a code which filters my post depending on my custom field. This code filters my posts depending on user role, and which custom field is selected. I successfully managed to filter my post ...
1
vote
1answer
23 views

Display featured image from one CPT within another CPT query

I have a WP_Query for a CPT of 'fixtures' that has a relationship with another CPT of 'fixtures_teams'. I want to pull in the featured image from the relative team in fixtures_teams CPT. $query = new ...
0
votes
1answer
14 views

how to load the comment template from a plugin

I want to create custom design for the comments. comments_template() will load the default \comments.php. i have a file inside my plugin commentsnew.php how can i use this file for comments_template(...
0
votes
1answer
17 views

How to create better WP_Query to look for date time which is anywhere between two meta values?

The following arguments are used for WP_Query to check if a reservation for a game can be created. Meta input fields for post are created using ACF DateTime Picker and set to Y-m-d H:i:s $start_date =...
1
vote
1answer
18 views

Get Current User Id Inside a Loop Returns 0 For a Shortcode

I am having function, which has a loop for all the posts of given author. I use get_current_user_id() but that does not seem to work while inside a loop, or may be the shortcode troubles it. My ...
1
vote
0answers
23 views

WP Query related posts by tags

I want to display related posts ordered by multiple tags. So I need to create a function what will query posts with the most number of tags in common and display them in descending order. But also it ...
0
votes
1answer
19 views

get_query_var always returns the default value

I am really new to wordpress, and I am trying to build a page that updates the database with given arguments. For example, if the client application calls https://codonmaster.000webhostapp.com/ranking....
0
votes
0answers
18 views

Possible to order archive by selected post IDs, followed by regular order with WP_Query

I can run an SQL query like ORDER BY FIELD( id, 3, 2, 1, 4 ), title and return a list of posts starting with my ids 3,2,1,4 and the continuing with the rest of a query, bringing back all remaining ...
0
votes
1answer
15 views

Search for single post by 2 tags

i have "Tag1" and "Tag2" i want to find most recent post with both tags.So far i have tried this, i know im close, but it is listing all posts containing either tag. $args = array( 'relation' ...
0
votes
1answer
10 views

How can I get custom post types to recognize pretty permalink variables?

I'm using PODS to create a custom post type called "automobile" on my site. This results in a permalink structure that looks like this: /automobile/automobile-page I want to be able to send ...
0
votes
0answers
17 views

Order by meta_key field in Wordpress not meta_value field value

I have a requirement where I need to show all posts having thumbnail first and ordered by title and then remaining posts ordered by title Below is the code I tried $the_page = (get_query_var('paged'...
0
votes
0answers
54 views

Wordpress custom query sorted by date and a boolean WP_query

I have a custom post type 'specials' that has 2 meta fields 'expiration_date' and 'featured' Featured is just 1 or 0 and expiration date is a date picker field from ACF I need to write a WP_Query ...
0
votes
1answer
25 views

a WordPress connected to 2 database

Is it possible that Wordpress works from two databases? I would like the post published by web A to be reflected on web B Web A would only affect the information in the tables wp_postmeta wp_posts ...
0
votes
0answers
12 views

pagination on wordpress and not showing all results

I have this page that shows posts from a range of years selected of a form on a previous page. the first results display the 10 posts as set in args(post_by_page => 10); if there are more posts I ...
0
votes
0answers
15 views

Is there any way how to obtain / filter out product variations using WP query by title?

I was wondering if there was a way how to filter product variations by titles using WP query. For example if we wish to delete only certain product variations from all products that are accepted by ...
0
votes
1answer
25 views

How to pass multiple custom fields as shortcode's parameters

I'm learning how to pass parameters in shorcode, I know the basic step after read through WP Codex. But for now, I have plugin come with custom fields and as the title, I want to know how to do it. ...
1
vote
0answers
10 views

How to show optimized list of posts with all their attachment images

In page-images.php template I have created this code which displays a list of posts which belong to a category and order them by meta value. So basically it is like a category page, generally nothing ...