Questions tagged [query]
A generic term referring to the process of retrieving information from a database.
1,874
questions
0
votes
0
answers
17
views
Optimizing AJAX Query with Large Database
I have a WordPress AJAX function that performs a location-based search on a website with a large database of over 100,000 posts... The function is responsible for querying the database to find the ...
0
votes
0
answers
26
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
11
views
Add a category to posts, that DO NOT contain two specific keywords?
i'm a little bit underwhelmed. I use mostly plugins for everything but i think there is none that does that job. I'm looking to add a category (ID 18663) to posts that do not contain two specific ...
0
votes
0
answers
20
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 ...
0
votes
0
answers
60
views
Sort posts by category and date using php and custom query
I am using Elementor Pro and Advanced Queries and also ACF for custom date. I have 2 types of posts that are events - event 1 and event 2.
I have an event calendar on the first page showcasing the ...
0
votes
2
answers
93
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
0
answers
9
views
Why does my search query loop double on the second element?
I'm writing a custom query for a wordpress loop that should match and filter elements into three categories 'premium', 'nachhaltig', 'guenstig'. I do that with a counting variable: $search_count.
At ...
0
votes
1
answer
19
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
16
views
How to modify the main query to show ACF fields
I have this code but the main query is preventing all ACF fields being displayed on the front end...
// Add a new admin menu item for the options page
function my_plugin_add_admin_menu() {
...
0
votes
0
answers
28
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
49
views
Exclude a category ID from the following function
I've used a query that will query if the post in a specific category, to show a list of subcategories it belongs to.
The problem I'm having is I also want to exclude a specific subcategory from the ...
0
votes
0
answers
16
views
Custom Filtering date with newsletter
Can anyone help me understand what the real problem with my codes i am trying to filter user with date range and newsletter. i already retrieved that using this function
$newsletter = get_user_meta($...
0
votes
0
answers
35
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
0
answers
19
views
Meta Query compare with LIKE pulls similar post types: 55 and 155, and 1,155
In my admin I have a CPT called Artists, and another one named Exhibits. I connect exhibits to artists via a relationship field in the exhibition cpt.
I setup a query on the artist page to pull the ...
0
votes
1
answer
89
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 ...
0
votes
0
answers
25
views
Restrict users to see only own comments and the post author's replies
I've chosen to use the default WP comments as private messages between readers/users and post authors, so that users are restricted to only seeing their own comments and the post author's replies. ...
0
votes
0
answers
74
views
Use value from meta key array for use in WP_Query
I have a CPT named 'Physicians', and have assigned an ACF field named locations to that post type — locations is an ACF post object field.
I also have a 'Locations' CPT and intend on displaying the ...
0
votes
1
answer
118
views
Query Loop Block: possible to restrict just child pages?
Is it possible to use the Gutenberg Query Loop block to restrict the output to just the page's children pages?
Or is it necessary to alter the theme?
0
votes
1
answer
119
views
SQL query to retrieve the number of WordPress posts with all given categories
I'm working on a WordPress blog filter function that shows all categories with posts. When the user clicks a category I want to show the number of posts at each categoryname that have the active ...
0
votes
0
answers
17
views
I am using the query block and what I want and see on the editor page is not the same with the actual results
I want my posts to be just as the first picture on a grid formation but when I save and view the page it shows otherwise.
0
votes
0
answers
91
views
How can I show a field ID in Elementor with Request Parameter
I have a ID Field called name and I need get this field in Elementor.
I don´t know if it show as get, post or queryvar.
Please, I need help
Maybe with
add_action( 'elementor/query/nameid', function( $...
0
votes
0
answers
13
views
How to show sticky posts on all pages of the pagination, not just the first page?
Good afternoon!
By default, sticky posts are only shown on the first page of the pagination:
http://example.com/
...but should be shown on all pagination pages at the top:
http://example.com/
http://...
0
votes
0
answers
18
views
Why does my shortcode query not working with search term
I have made code to display posts by search term, but it is not working.
/**
* Display posts.
*/
function dispost($atts, $content = null) {
global $post;
...
0
votes
0
answers
63
views
Use Base-URL with Query-Loop
I've set the Base-URL for my WordPress page with <base href="https://www.example.com/" />
function custom_header_metadata() {
?>
<base href="<?php echo ...
0
votes
0
answers
12
views
Batch Scanning and Deleting Empty WordPress Posts
I found a solution, How To Delete Post's With Empty Content Using WP-CLI. I am Looking For a SQL Query Version That Will Delete All Post's Eith Empty Content.
Here Is the WP-CLI Version-
wp post ...
0
votes
1
answer
165
views
How to figure out correct wp_options to have autoload='yes'
I have a website that has suddenly become slow. I don't know what caused the change. I haven't installed new plugins, and I don't think I recently updated any plugins. Upon inspection with Query ...
0
votes
0
answers
23
views
Searching for a custom meta from user.php in the admin
I am trying to extend the standard user search to 1 specific custom usermeta.
I am following the great answer provided in this question.
I am still not able to get any result when I search for this ...
0
votes
1
answer
68
views
Load posts via AJAX without draft status
When I load posts in the frontend via AJAX, I also see posts that have the status "Draft":
function get_projects() {
$args = array("post_type" => "project");
$...
0
votes
1
answer
40
views
Search results stuck on page 1
The problem statement
For some reason when the user does a search the results page (search.php) only show the first page results. The pagination (next and previous links) also believes its on page 1.
...
0
votes
0
answers
29
views
How to use a dynamic term id for the query block
I'm attempting to add a template part to a custom post type template in the site editor by creating a custom block variation for the query block that has the post type selected by default in the ...
1
vote
1
answer
225
views
Sorting a custom post type in pre_get_posts
I have a custom posttype "Talks" which have a custom field name start_date. The posts start_dates are the the past and in the future.
I need the future posts to come first with the ...
0
votes
0
answers
515
views
Querying Posts from ACF Repeater Subfield Select Value
I am attempting to query posts based on the value of a repeater subfield dropdown (select field) but am having trouble.
Here is what I am working with:
<?php
// Set up the arguments for the ...
0
votes
1
answer
29
views
Use meta query only 3 or more results?
Using elementor I'm currently running the following:
add_action( 'elementor/query/model-query', function( $query ) {
$meta_query = $query->get( 'meta_query' );
$meta_query = array();
...
0
votes
2
answers
79
views
User Query Multiple Orderby Clause
I'm having trouble getting consistent results from a WP_User_Query when ordering by multiple meta values.
There is a meta field that contains a serialized list of IDs, and I need to display users with ...
0
votes
0
answers
45
views
Display all child posts in a custom post type, grouped by a custom taxonomy site
I successfully use this code to Show Child posts on the Parent post page via shortcode:
global $post;
$args = array(
'post_parent' => $post->ID,
'posts_per_page' => -1,
'...
0
votes
0
answers
45
views
Search query alteration not working for meta values
The bellow code works on category archive pages, it filters out the necessary products. But on the search page it doesn't work. If I uncomment the line //$query->set("s", "chelsea&...
1
vote
1
answer
79
views
Query Multiple Filters, one with Meta
I am trying to write a Buddypress Query (similar to WP Query).
(1) It must pull all activity entries from a specific user id; regardless of meta mentioned in number 2.
(2) It must also pull activity ...
0
votes
0
answers
21
views
Can I log the searches that are returning 404 in the DB?
I would like to log every single search query for which one gets 404. For example, if I search Cat in the search box, but my website doesn't have any content as cats. I would like to log that "...
0
votes
1
answer
22
views
Can I create my own query in wordpress with traditional methods?
I am new to developing themes with wordpress, so here's my question. Can I create my own query in wordpress with traditional methods?
I know we use the WP query methods, but what is the most efficient ...
0
votes
1
answer
171
views
Modify a query using both a text field and a true/false AFC field
I am using the following code to modify the CPT "movimiento" query.
add_action( 'pre_get_posts', 'mov_vec_archive_page' );
function mov_vec_archive_page( $query ) {
if ( !is_admin() &...
0
votes
0
answers
15
views
Get posts that were most recently tagged
Is it possible to query posts by tag that have been tagged most recently?
For example.
Post A published 10/1
Post B published 10/2, tagged "new" on 10/4
Post C published 10/3, tagged "...
1
vote
1
answer
44
views
3 queries to update WordPress
I have been out of the game for a few years so this is difficult. I remember that there were 3 queries that I used inside CPanel when moving a site. they would update the database name and table ...
0
votes
0
answers
33
views
SQL query to rewrite all media URLs to end with .webp
I have manually converted all media files within the 'uploads' folder to .webp,
I have maintained the folder structure, every .webp image remains in the same folder its predecessor was.
How do I ...
0
votes
0
answers
33
views
'Active lotteries' only custom query for woocommerce lottery plugin and elementor
I am wanting to create a custom query that returns only active lottery products on my lottery 'style' website. I have been given a query but I am not sure where this query should be placed in my ...
1
vote
1
answer
57
views
Prevent executing query for wp_global_styles
I'm inspecting a site I'm maintaining using query monitor plugin and I noticed this query being executed:
SELECT
wp_posts.ID
FROM
wp_posts
LEFT JOIN wp_term_relationships ON (wp_posts.ID = ...
0
votes
0
answers
28
views
Can Wordpress support Website (19GB database) Should I move Our Wordpress Website to a custom one using Laravel or any other PHP framework?
QUESTION: Should we migrate our website to a custom build?
PROBLEM:
We run a WordPress website that currently has 19GB of MySQL Database data aside from images.
We are facing issues such as site speed,...
0
votes
0
answers
38
views
AJAX loading with custom parameters
I have a CPT set up with some custom taxonomy and I've created some custom searching functionality that works great with it, ( a user can search by keyword, industry, specialty, location, or all 4 or ...
0
votes
2
answers
113
views
Checking if the query is empty does not work
I hope you have a good day.
I get a query from the database,
If the query is empty, the message "Register" will be displayed
Otherwise, the message "Register" will be displayed
See ...
0
votes
0
answers
153
views
How do I troubleshoot Maximum execution time of 60 seconds exceeded in updating a Media File?
I'm on a shared hosting plan. Getting this error log entry when the user tries to update any field on a Media Attachment.
[13-Oct-2022 20:10:05 UTC] PHP Fatal error: Maximum execution time of 60 ...
0
votes
1
answer
468
views
Query filter on custom post by current author in post widget for elementor query id
I am using post widget in elementor pro. Idea is to show all posts by a specific custom post type. Now, I want to apply also some filters in particular I want to show only posts in a particular status ...