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
1answer
21 views

Counting instances of words in the results of a post query

I'm way over my head with this one and wonder if anyone can shine a light on where I'm going wrong. I am grabbing some authormeta for the resulting posts of a query, and I want to tally up the number ...
0
votes
1answer
19 views

Search filter between promo and exact price

I've got lots of posts with promotional prices and the rest have an exact price. I just wanted to make sure that if promotional price exists, use the promotional price as the target data when I try to ...
0
votes
1answer
35 views

WP Query Meta Value - How To Identify Specific, Unique Values?

On my Club Profile pages, I'm displaying a list of posts (Player Profiles) where the title of the specific Club Profile page is also a meta value contained in those Player Profiles against one or two ...
0
votes
0answers
32 views

query hook parse_tax_query function takes no effect

I'm trying to build a function (inside a plugin), which limits the shown posts to the time a logged in user is registered in weeks. (So if a user is registered for 4 weeks the categories page shoud ...
0
votes
1answer
32 views

How is $current_page passed in woocommerce_account_orders function?

The woocommerce function woocommerce_account_orders($current_page) has 1 parameter called $current_page. The function is called via woocommerce_account_orders_endpoint via the following hook - ...
0
votes
0answers
8 views

Query posts according to previously selected categories of logged in user

How do I query posts according to categories that a user selected at registration? The posts would be from a custom post type and match with existing post categories + custom field categories from ACF ...
1
vote
0answers
7 views

Display Featured Post by Categories and Avoid duplicated posts

I'm learning Wordpress development on Udemy and currently developing a theme. I haven't added any custom taxonomy but just using the "Post" and "Categories". Found a tutorial of ...
3
votes
3answers
413 views

Does WordPress sanitize arguments to WP_Query?

This is a very straight-forward question, but it's important and I can't find anything definitive in the docs. This question asks a similar question for the 's' parameter, specifically. I want to know ...
-1
votes
2answers
67 views

How to Delete Posts by title?

I have about 2000 titles. How can I automatically delete posts with these titles? For example
0
votes
0answers
21 views

Order post by modified date

I'm trying to return on the blog page the results in post edit order. Everything is working, I just have one problem. The first 3 posts in the blog are out of sync and are not being returned based on ...
0
votes
0answers
41 views

how to include author in custom post type search

I have a search field where a user can type in something to search a custom post type. This works okay if the word exists in the title but not in the content. Also, I want to include authors in the ...
0
votes
1answer
124 views

get term id from term name

Hi i am trying to get term id from term name (title ). <?php if ($_SERVER["REQUEST_METHOD"] == "GET") { // collect value of input field $nameb = $_GET['fname2'...
0
votes
0answers
42 views

Property 'post_type' of non-object produces Internal Server Error

Apache error logs have been auditing the following issue for over a week: [Thu Apr 29 19:50:24.673774 2021] [proxy_fcgi:error] [pid 19464:tid 139936082659072] [client 12.34.56.789:1000] AH01071: Got ...
0
votes
1answer
279 views

Wordpress sorting posts by date and title using a dropdown

I'm trying to set up a dropdown that would sort my posts by Newest to oldest and Alphabetical. This is what I have so far: I'm declaring an empty variable, then a form where I can change the contents ...
1
vote
0answers
31 views

Search by post title and content in wp_query without order

I am trying to do a search engine, I am using get_posts () function with parameter 's'. It finds me post by title and content but in a disorderly way, how could I tell it to first consult the titles ...
0
votes
0answers
19 views

How do I check if a NESTED ARRAY meta value array contains an item name? [duplicate]

I'm adjusting an archive page to only show products where a certain ACF meta field has a specific value but its not straight forward as the meta value is a nested array so I'm struggling to check if ...
0
votes
0answers
17 views

Get taxonomy name by tax-query in posts list

I have ajax category filtering and I use it to get taxonomy id and list posts by taxonomy. Now I want to show current taxonomy name in list view. I have trying to add <h4>get_cat_name((int)$...
0
votes
0answers
18 views

WP Query - Query Posts that are in range of two acf fields

I have a custom post type, where the posts have some acf fields. my fields are: periode: 'Beginner' startperiode: 1 So here are the query args, which i have used to get all posts from a phase and a ...
1
vote
1answer
25 views

Fetch taxonomies by custom post type id array

I want to find all the taxonomies that match an array of CPT id's. I have a taxonomy called location and I want to find all the locations where they have posts that are equal to my array of post id's ...
0
votes
0answers
28 views

Custom search query on Wordpress page not working

I have made a custom page for an university website where all the available scholarships are listed. User can specify city, degree, intake, scholarship type and language to search for universities ...
0
votes
0answers
33 views

WP query posts BUT show the most recent and one per author

I want to display 12 articles first goes the latest BUT i want to show only one post per user. For example if user A wrote 2 artticles today i want to display only the latest of his articles. Here is ...
1
vote
0answers
64 views

How to use $query->set with post__in?

I use the pre_get_posts hook to change the search results because I have a filter form. This hook gives me access to an already made $query object. This line does not work: $query->set('post__in', $...
0
votes
0answers
11 views

Getting list of categories that have posts in search results

Looking for a solution for the following problem. I am trying to create a list of categories that contain posts in a results page. Ideally this would also contain a post count. Up to this point I ...
0
votes
0answers
28 views

Query posts by post type, author and post meta

Bit of an awkward one here, and there may not be a solutions within current WP core. Basically I have a CPT called "connection" with a custom meta field called "outcome" which ...
0
votes
1answer
128 views

Get user first name from custom endpoint

I am trying to set up a custom endpoint which only returns some user data instead of the default data sent back by the users endpoint. But I don't know how to get the first and last name of the user ...
0
votes
0answers
14 views

display comment type count of post single page

I have comment type. when author marks any standart comment. standart comment convert to sticky comment type. but how can I display sticky comment type. This stikcy comment is used as accepted answer ...
0
votes
0answers
19 views

How to Get Post Id on Page

I have created a custom post linked post to custom page URL instead of post detail page. But now I want that post id on custom linked page. So please help me how can I get post id on that particular ...
0
votes
0answers
19 views

Is it possible to give a classname to specific comments in the Wordpress admin?

Is this possible? I'd like to go into wp-admin, click on a comment and give a class for a specific comment. Would it be possible to do so? If so, could you please help?
0
votes
0answers
39 views

Change Old Wordpress Post Date Year

I have old WordPress posts that were published way back in 2017, 2018, and 2019. I would like to republish this content. Basically, what I want is that all content from 2017 to be republished in 2021, ...
0
votes
1answer
153 views

Populate select list with meta values from all posts of a Custom Post Type

I've got a CPT of Inventory and I'm trying to show a dropdown of all Mfrs. I've got the form and pre_get_posts function so that when a user selects a Mfr, the page refreshes and shows only the ...
1
vote
0answers
115 views

DROP TABLE with uninstall hook not working

I wanted to explore more options and thats the reason for me building my first WP Plugin. I tryed to follow the coding standards, but I am struggeling hard right now. I am trying to drop my created ...
0
votes
0answers
12 views

How can I display a category page with future sub categories?

In a recent project I had to build a custom category page. On this parent category, I display sub categories.(just thumbnail and title) Some of these subcategories'posts will be published in future. ...
0
votes
0answers
11 views

Query post by one taxonomy and sort by another

I am getting the posts by a custom taxonomy called "wall_of_fame". This gets me all the posts that match "Yes" in this custom taxonomy. $query_args = array( 'post_type' => '...
0
votes
1answer
43 views

How can I style future post?

I'm showing published and future posts on a category page. I need to make future posts unclickable and add a special class to them in order to add a gray overlay, meaning the post is upcoming.. trying ...
0
votes
1answer
29 views

Display post count for a specific month

I am trying to display post count for a specific month, But something is wrong with my query because count is wrong. here I want to get post count for Aprel month. Can anyone help me please ? Thanks ...
1
vote
1answer
17 views

How to show CPTs in term archive

I attached default taxonomy "category" to a "story" custom post type, when I register it: 'show_in_rest' => true, 'show_in_feed' => true, 'taxonomies' => ['...
0
votes
0answers
15 views

Order By Custom Field, otherwise by Date?

I have two CPT and want to order them with Events first, then Articles. Events should be ordered ASC by wpcf-date_time - the event's date, which is in the future. The Articles should be ordered by ...
0
votes
1answer
75 views

pre_get_posts pagination not working

I've been trying to fix my pagination on for category pages but am at a loss. This is my pre_get_posts function for category pages. add_action( 'pre_get_posts', function ( $q ) { if ( !is_admin() /...
0
votes
1answer
14 views

Does WordPress have something like Drupal's DB API?

That is, the ability to write database queries like: $query = db_select('users', 'u'); $query->condition('u.uid', 0, '<>'); $query->execute(); I'm converting a Drupal site to WordPress, ...
0
votes
1answer
81 views

Shortcode Not Working in Slider When Added To Post Title

I've coded a shortcode to add manually to specific post title fields so i can style part of a title add_shortcode( 'green', 'green_shortcode' ); function green_shortcode( $atts, $content = 0 ) { $...
0
votes
0answers
41 views

Prevent Duplicate Post Counted by Query

<?php while ( have_posts() ) : the_post(); $get_series_id = get_post_meta( get_the_ID(), 'series_seri', true ); if (in_array($get_series_id, $do_not_duplicate)) { ...
0
votes
0answers
30 views

How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?

The Setup I have divided my blog into 3 categories with their respective slugs. There are 3 pages corresponding to these 3 categories with their respective custom page templates. On each page, I ...
0
votes
0answers
48 views

How to query results for post_title and Custom Post Type/ACF field pivot query

I have a custom query that needs to match a search term to a custom post type of event by post title and by an ACF field host and then filters out events that have passed the current date to a REST ...
0
votes
0answers
16 views

get_the_excerpt doesn't work with default items but works with my customs post types

the excerpt function not work in my custom post template using Wordpress default posts in the query loop, but they work fine with custom post type. I enabled the display of excerpt by checking the &...
0
votes
0answers
41 views

meta_query not behaving well with spaces

I have created a custom search page where i can search in a Custom Post Type (Products) based on a number of custom fields that each product post has. This is the search input: <form role="...
0
votes
0answers
13 views

Taxonomy list inside the query

Is it possible to get a list of the "terms of taxonomy" or "just used taxonomy types" defined within that archive without looking at all pages of an archive query in a loop? What I ...
0
votes
1answer
41 views

WP_Query: how to search tags in addition to a custom post type?

Below is what I have so far for a custom rest endpoint ('placesdb/v1/search?term=') for a custom post type (place). This successfully returns all the places that have the search term in the title or ...
1
vote
1answer
139 views

Filter wp_query to search post title in function

I'm making a query to pull posts from my post query based on a user entry in a form. I want to keep the form simple so I'm hoping to only have to use one field. That field would say search part ...
0
votes
0answers
36 views

How to Ignore Specific/Common Words in Wordpress Search Query?

I am facing a strange problem with the search engine of my WordPress website. I want to turn off the case sensitivity of my WordPress search engine. For example if a user search "apple of one's ...
1
vote
0answers
24 views

Getting post revision and printing them on the post content site

I trying to print older post revisions on the content.php site (theme: twentytwenty), and this, with staticly set value works.. $query = $wpdb->prepare("SELECT * FROM {$wpdb->prefix}posts ...

1
3 4
5
6 7
110