Questions tagged [query]
A generic term referring to the process of retrieving information from a database.
1,895 questions
0
votes
0
answers
19
views
Change Query Var from s to q
Hi I have kind of an unusual task that I'm not sure exactly how to approach. I would like to change the query string shown in the url bar to use “?q=” instead of “?s=”
I am using Elementor as well as ...
0
votes
0
answers
5
views
Display all products outside of filtered function
I have a products page which displays products based on filters. I believe I have found the code in which all of the products are queried. Normally, if a customer selects an attribute such as '...
0
votes
0
answers
12
views
Issues applying JSON body filters in EU F&T Portal SEARCH API with WordPress integration
I am trying to use the SEARCH API service of the EU F&T Portal public REST APIs for retrieving data for further integration with my project, but I am having some problems. I am using WordPress as ...
0
votes
0
answers
8
views
404 with google ads query params
any idea how to fix 404s for existing pages caused by Google Ads query params?
See following in access log
www.hedonia.sk 85.237.224.49 - - [17/Oct/2024:06:39:27 +0200] "GET /aktualne-obaly-pre-...
1
vote
1
answer
288
views
SQL errors when querying for something with apostrophes
I have the below PHP function that queries some custom database tables and outputs the result. This generally works great, except for when I put an apostrophe in the query; for example, "Men's&...
1
vote
0
answers
19
views
Dinamis Query Loop template Custom Post Type dan Taxonomy di WordPress Blocks dengan PHP
Google Translated:
Hello everyone,
I’m trying to create custom blocks in WordPress that dynamically
display posts from custom post type that I’m creating, which is
“products”. I also want to sift the ...
0
votes
1
answer
34
views
Primary menu item is not highlighting when page is active even though it is linked from a url with query string to pre-populate a form field
I'm using the WordPress Astra theme. I have set Astra customization to highlight the active page primary menu item in the navigation bar. However, when I link to the "Contact" page using an ...
0
votes
1
answer
35
views
Function wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder
I am getting the following error: Function wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder. I have gone through plenty of other similar questions ...
1
vote
1
answer
87
views
Problem in MySql query on Wordpress [closed]
According to https://developer.wordpress.org/reference/classes/wpdb/
I'm trying to retrieve a value in a WP table with a simple query
<?php
global $wpdb;
$results = $wpdb->get_results( "...
0
votes
0
answers
12
views
Struggling to edit the width of text in 'Variations' template
I am struggling, using the "Variations" template, to extend the paragraph text to fit the whole screen. I've googled and it comes up with lots of instances of variations, and I've searched ...
0
votes
0
answers
21
views
"Page Not Found" with multiple last pages of query
Issue
When accessing the URL https://192.168.1.100/page/30/ in WordPress, I receive a "Page Not Found" error. The query has a maximum of 50 pages, with pages 1-29 displaying correctly. Pages ...
0
votes
0
answers
38
views
taxonomy pages returning “NULL” when running default WordPress function 'get_queried_object()'
i keep seeing the following in the php error log, repeating:
[05-Aug-2024 02:34:41 UTC] PHP Warning: Attempt to read property "post_content" on null in /home/euognau/public_html/wp-content/...
0
votes
0
answers
14
views
Remove posts that start with similar words (like a delete duplicate posts plugin)
Can anyone advise on a SQL query or plugin (or any other solution, as I haven't been able to find any) that can delete all posts that start with the same words, except the oldest of them? Or maybe to ...
0
votes
0
answers
53
views
is it possible to get a list of URLs from post_content directly in a mysql query via phpadmin?
We have many forms that are hosted externally from our Wordpress environment that we are moving to a different system, so we'd like to generate a list of the pages that contain these links along with ...
0
votes
0
answers
37
views
Advanced Custom Fields in WP_Query: Href Returning Empty
I'm still learning the ropes of PHP so please bear with me!
So basically I have an ACF URL field "author_link" that I want to generate on a "table of contents" page in a list ...
0
votes
2
answers
38
views
Is it possible to extract all product columns except for one?
I currently extract all product data in CSV format.
There is also the option to select columns too.
However, I sometimes want to exclude just one particular column, or maybe even a few others.
...
0
votes
0
answers
49
views
Filtering custom post type list in admin by custom meta key/value
I am trying to add an additional filter to be able to filter by a custom meta value but it is not returning any values when I would expect it to.
Here is my code to add the filter dropdown (this seems ...
0
votes
2
answers
98
views
How to use meta_query to retrieve posts from multiple custom post type
I am having two custom post type "meet_our_community" and "news"
I have added a checkbox field named 'add_to_meet_our_community' from the acf to 'news' post type.
Now I when tried ...
0
votes
1
answer
108
views
Modify WordPress Search
I'm facing a challenge with a WordPress project and I would appreciate the community's help in solving it.
The issue lies with the search functionality. When customers type in a search term, such as &...
0
votes
0
answers
32
views
Block Editor - Wordpress 6.1 - CPT Archive Issue - While the title changes in the loop, all records display the same data
I am using the block editor with CPT. I have a loop that iterates though my CPT. The title changes for each record but not the data in the CPT. I am using a shortcode to display my custom post type ...
1
vote
0
answers
26
views
Can I filter existing search query using pre_get_posts for post_mime_type?
I have a search page with a custom filter that I use to only retrieve posts of 'attachment' post_type. Here is a greatly shortened version:
function MySearchFilter($query) {
if( ($query->...
0
votes
0
answers
92
views
$wp_query->found_posts; returns zero
I'm merging 2 queries using the code below and it works as I expected except for the $main_query->found_posts; returning 0.
$args = array(
'post_type' => 'carellcars',
...
0
votes
0
answers
25
views
Can I make a Heading block above a query loop block disappear when that query loop has no results?
I have a query loop that disappears (by design) when it has no results (by not including a "No Results" block). I would like to find a way of making the Heading that precedes the query loop ...
0
votes
1
answer
19
views
How to use parse_query() to add an additional filter based on content to page search?
I want to add another filter box to my admin "pages" screen, let's call it search2.
I want to be able to filter the results that I searched to be limited to only pages that contains search2 ...
0
votes
2
answers
43
views
Pre_get_comments and orderby comment_karma
I have ratings on a custom comment type that stores the ratings in the comment_karma meta of the comment. Now I want to pull up the comments for a specific user and sort them by rating. Here is what I ...
0
votes
1
answer
49
views
how to ensure url uses post_name and not query post id?
the situation :
my settings > permalinks are sets on post name, but sometimes anyway a post url is using the query post id :
https://my_website.com/?p=4348 instead of https://my_website.com/my_post
...
0
votes
0
answers
23
views
Get URL parameters with rewrite rules
We have some rewrite rules and would like to get the url parameters on that pages/feeds.
That does work on regular feeds, but not on those with a rewrite rule.
On regular feeds like https://domain.com/...
1
vote
1
answer
499
views
Using Query Loop Block to list all posts under each category
I am using Query Loop Block to list all posts under a custom post type. But I want to display all posts under each individual category, is that possible using query block?
Something like this:
...
0
votes
1
answer
60
views
Sort users in admin screen by meta value whether it exists or not
I want to list all users and order them by a meta value. Several users have it and some do not, but I want to be able to list them all and group them accordingly. I have the following code but it only ...
0
votes
0
answers
30
views
Hot to show custom post type taxonomies on archive page
I have a custom port type 'apartments' and each apartment has several parametres which I made into custom taxonomies, like 'number of rooms', 'area', 'region', 'status', etc.
The task is to show all ...
0
votes
1
answer
99
views
How to get parent and child sub category (Taxonomy) order to display
Trying to get my list of categories to display the child after the parent.
For Example
Parent Category
Child Category
child category
Parent Category
child category
Current code
<aside ...
0
votes
2
answers
417
views
Querying by post category slug with core/query block markup
I know how to query all posts in a certain category by slug with WP_Query. What I would like to do is the same with the core/query block markup. I am able to get it working with the category ID, but I'...
0
votes
1
answer
125
views
Elementor - Sort by name
I have a website that lists paintings. All these paintings are made by various artists. I've added a custom post type "paintings" and created a form so each painting can be easily entered. ...
0
votes
0
answers
35
views
Include posts under a custom taxonomy in author.php
The author’s archive (author.php) on the website I’m working on displays only the posts by the current author.
I have a custom taxonomy called “co_writer” which I use to simply tag a post as having ...
1
vote
1
answer
308
views
query loop "inherit query from template" prevents setting sort order
I need all auto-generated category pages to sort oldest-to-newest
I'm editing my "All Archives" template in block editor but I'm not having any success
it contains a query loop with "...
0
votes
0
answers
194
views
Rewrite URL custom search query
I have this url:
mydomain.com/?s="SEARCH TERM"&categoria="WORDPRESS CATEGORY OF POSTS"&province="CUSTOM POST FIELD"&poblacion="CUSTOM POST FIELD"
...
0
votes
1
answer
58
views
Query Multiple Post Types and Paginate Newly Created List
I know this has be asked several times but i cant seem to find the answer anywhere. My site has a resources page which is my archive for all resources (archive-resources.php).
I'm trying to also ...
0
votes
1
answer
139
views
Multiple queries and pagination
I have a homepage and an archive page where I call a template part to have a hero section for the most recent posts, and then loop through the remaining posts as usual.
Essentially I don't want to ...
0
votes
1
answer
68
views
posts_per_page showing 16 elements instead of 3
I need help with this. Whatever I add to 'posts_per_page' value, it shows 16 posts for some reason..
<?php
$args = array(
'meta_query' => array(
array(
...
0
votes
0
answers
122
views
pre get posts not working with Tribe Events
I am using the events calendar by modern tribe.
They claim this defaults to showing events in the main loop by event date. This is not what I am seeing on my site. I downgraded the plugin and it works ...
2
votes
0
answers
106
views
How to make query loop block dynamic
I am looking for a tutorial to figure out how to set the query loop block to get its category from the post it is in so I only set it in single post template not in every post I wanna create. Is that ...
0
votes
0
answers
59
views
Display featured posts first, then display all others within a specific category in WordPress
I want to display featured posts first, then all other posts not marked as featured on a category archive page. I am using a plugin that has functionality to mark posts as featured. I have figured out ...
0
votes
0
answers
10
views
Custom API how to return int field
I have a custom table in db with a column recommendation of type int(11).
Then as one of my custom route handlers I have
global $wpdb;
$query = "SELECT recommendation FROM `restaurants`;
// ...
0
votes
0
answers
170
views
Getting the correct post ID in Wordpress query loop
I'm trying to add custom field values inside a Wordpress query loop, so that I can have a list of titles, excerpts, and extras like start ratings in the loop results. I want to use something like echo ...
0
votes
0
answers
26
views
import/view table from external site
Good morning
I state that I am a novice user and I would kindly look for someone to help me solve the following problem:
I would like to know if it was possible to view directly on a page c/o menu of ...
1
vote
2
answers
677
views
Why does $_GET return values but get_query_var does not?
I have a bunch of query parameters that have been added with add_filter( 'query_vars'. I'm subsequently querying these with get_query_var like so:
$search = '' !== sanitize_text_field( get_query_var( $...
0
votes
1
answer
68
views
Optimizing or rewriting core queries
I am new to customizing WordPress and plugins core functions so I have a questions.
Query monitor says I have a duplicate query that is executed like 13-14 times. The query in question is:
SELECT ...
0
votes
0
answers
34
views
How to get posts that have certain meta key value and order based on another meta key's value
Here is the code I gathered off the internet so far:
$args = array(
'post_status' => 'publish',
'posts_per_page' => '5000',
'post_type' => 'post',
'meta_query' => array(
...
0
votes
0
answers
62
views
Advanced Search - Is this possible?
I am currently working on a Wordpress website that needs an advanced search adding to it.
I have three categories set up, each with a set amount of sub-categories, and then I'd like for a user to be ...
0
votes
1
answer
238
views
Change permalinks in posts via SQL
I have changed our permalink structure for a better SEO Score. Our old was day and name like https://domain.tld/%year%/%month%/%day%/%postname%. On our site are around 2600 posts with links to other ...