Questions tagged [query]
A generic term referring to the process of retrieving information from a database.
1,841
questions
0
votes
1
answer
14
views
What is the best way to cache pages on Wordpress
I have a site with many custom queries. Some take many seconds to load a page. To solve that issue, I have been using a caching plugin. The issue is, my caching plugin does not cache a page until I ...
0
votes
1
answer
32
views
How to get comment images stored as serialized comment meta
I want to display images under for each comment but images store in database as serialized a:3:{i:0;i:775;i:1;i:776;i:2;i:777;}
I wrote this code
print_r (get_comment_meta( $comment->comment_ID , '...
0
votes
1
answer
26
views
Get all comments of author's posts
Hello I have multi author website. I want to display all comments of posts created by author in author page. Please help me. I found this code but fatal error
<?php
$args = array(
'...
0
votes
1
answer
15
views
Change the destination of the URLs in post.php
The post.php screen lists posts vertically in the admin area [and other post types]. Each item's post_title is a hyperlink, directly above some inline choices. Both the title link, and the "Edit&...
0
votes
0
answers
17
views
Comment Table Size Results in Slow Page Loads and 500 Errors
I manage a small site that has a very active comment area. The site is on shared hosting. There is a daily post entry, then a robust comment area. It is not untypical to have more than 100 comments on ...
0
votes
0
answers
82
views
SQL query - get a featured image's alt / alternative text
I am writing some SQL queries to get post data out of a database for certain posts (so WP functions are not an option). I am trying to get post IDs, post URLs, post featured image URLs and associated ...
0
votes
0
answers
11
views
Pagination not working on custom post types with rewrite slug
I've been trying to fix my pagination to work on custom post type slugs for example article/post-title/page/2 it just keeps showing the first page's results, the URL is changing but the posts remain ...
0
votes
1
answer
21
views
get products by custom date variable
i have a product attribute called review_date, and i would like to order these products by that date. I haven't seen a working solution yet.. what am I doing wrong here?
$args = array(
'...
0
votes
0
answers
9
views
Sort query_terms_list for post_tags alphabetically
I have the following array that currently sorts tags by tag count and returns the tags with the individual tag count. I would like to keep the individual tag count but sort the tags alphabetically ...
0
votes
0
answers
7
views
Compare User meta_value with Product meta_value
In Wordpress I've added a new field called "user_branche" on the user edit profile page within the admin. On the Woocommerce product page in the admin I added a meta field called "...
0
votes
0
answers
14
views
Display the same randomized query results on browser-back
I'm creating a query based on certain criteria and if the returning query yields more than a displayable amount of hits, I rand them. Which works great except if people navigate away from the query-...
0
votes
2
answers
25
views
Check if an option exists and get its value in one hit
I have an option admins_settings that has an array of sub-options that is stored in the wp_options table. Before I get its value from the table, I check if this field exists by running this code:
if ( ...
0
votes
1
answer
15
views
How to get a random single category name in get_posts()?
How can I get a random category name one at a time?? The post may have multiple category instead of a single category. I just want to show a single category name in the post grid loop.
$...
0
votes
1
answer
17
views
Include current post into loop
I have a related posts loop ( in every single post page ) based on post title. source : https://wpza.net/get-related-posts-based-on-the-posts-content-in-wordpress/
But I also need to include current ...
0
votes
1
answer
43
views
Query multiple taxonomies with pre get posts
I am trying to query a custom post type based on what a user inputs into a form, I am having trouble querying multiple taxonomies in pre_get_posts filter, I can't seem to find a way to set the query ...
0
votes
1
answer
17
views
Target a page with query
I have those 2 pages that are created from a plugin (see the plugin https://zombify.px-lab.com/frontend-page/, just login and choose a post type, check the url):
https://www.domain.com/post-create-...
0
votes
0
answers
24
views
Improve performance of slow query
I'm using this query to obtain all the products buyed by user and works but query monitor says me that is a slow query (above 0,5 sec), there is a way to fix this?
Here the db query:
$result = $wpdb-&...
0
votes
0
answers
12
views
How do I set the Stewart Search Template to return only published posts in the result
I recently took a WP.com online webinar and the moderator referred me here to ask my question. I am trying to redesign my site using FSE. I am using the "Stewart" theme.
I have added a ...
0
votes
1
answer
27
views
Page with custom template make get request to a custom route - Pseudo code
I created a page with a specific template and when the page load I would like it to make a get request to a custom route.
So far I am using JS and axios to make the request onload but I was wondering ...
0
votes
1
answer
23
views
Reject all malicious URL requests functions.php
this might not be the right place as it's a question about a function snippet that relates also to the server and log files.
I have been trying to block access to my site from bad query attempts which ...
0
votes
0
answers
12
views
Multi-layered WP_Query
I'm trying to avoid creating additional custom field for one of the posts, and was wondering if there is a way to query WP DB to retrieve the necessary data.
I have 3 types of posts: Events, Programs ...
0
votes
1
answer
23
views
Load specific page when a custom URL is hit
I'm building a plugin which will basically build a knowledge base dynamically, by retrieving categories, articles, etc. from an external API where all documentation is being kept.
I've added a few ...
0
votes
1
answer
14
views
How to divide Subcategories into pages of parent category wordpress
suppose I have sturucture like this:
Justin Bieber > Albums > Justice
when I visit on https://example.com/category/justin-bieber/albums/
It is showing all albums of Justin Bieber category. but ...
0
votes
0
answers
5
views
List only parent attributes on woocommerce admin atrributes page
I would like to add option on attributes page screen options, to filter out only parent attributes.
The main struggle is that I can't even alter the query... I tried actions: parse_query, ...
0
votes
0
answers
13
views
`offset` WP_Query argument dont work via `pre_get_posts`
I have some weird problem because pre_get_posts filter completely ignoring offset argument.
Here is function from functions.php file:
function custom_category_query (WP_Query $the_query) {
if ( !...
1
vote
0
answers
33
views
Overwrite YoastSEO meta-tags with another page's [closed]
I'm writing a custom Wordpress theme and for a specific page I need to overwrite its meta-tags (printed by YoastSEO) with the meta-tags of another page I already know the ID of. I cannot just change ...
0
votes
1
answer
21
views
Filter products on category AND tag
I want to be able to filter products based on category AND tag, as well as sub category AND tag. From my research I heard that I must write some kind of rewrite rule in functions.php for this to be ...
0
votes
0
answers
19
views
Display posts ONLY from the current logged in user and current week/year/month Elementor posts
I want to show the posts my users have added in three different sections. That would be "Your Posts from This week" and so on. I am currently using:
add_action( 'elementor/query/currentuser',...
0
votes
0
answers
17
views
How to search post titles with whole words only, but not the exact word only?
I'm using WP Custom Fields Search plugin for my search but am searching the core post title field. The default search is including results where the word is part of another word. For example, ...
0
votes
0
answers
31
views
Using One Function To Create Two Different Shortcodes
To populate a player rollcall, an extensive query pulls data from tables in my external MySQL database. Part of this also extracts the player(s) who a) made the most appearances and b) scored the most ...
0
votes
0
answers
14
views
Advanced Query posts
Who can help me with this query:
I try to build a search function that looks in the post_title and in some meta value's
What I have so far
$args = array(
'post_type' => 'catalog',
'...
0
votes
2
answers
57
views
List custom queried terms in the edit-tags.php?taxonomy page
This is my first time posting a question here.
I have this problem that I feel that I am soooo close to solve, but can't manage to do it.
I have a custom taxonomy called "aplication" and ...
0
votes
1
answer
24
views
Set front_page programatically after user login via query, while leaving site option alone
I want to change the front page based on who is logged in.
If User_Bob is logged in, the front page is "Bob" [post id: 123]. If User_Jane is logged in the front page is "Jane"[post ...
1
vote
1
answer
21
views
Custom WP Query: force entry for some taxonomy and have others optional
I am creating a search with a form to select specific taxonomies.
The search requires 2 items to be entered, and then has 3 optional terms. All of these are custom taxonomy terms. So once the user ...
0
votes
0
answers
16
views
WP_Query 's' prioritize direct title matches over description text
Is it possible to get search results back where hits that matched the title rank higher than hits on the description? Or alternatively achieving this with something like orderby?
$the_query = new ...
0
votes
0
answers
9
views
query variables for custom taxonomies
Is there a way to encode custom taxonomy and term as query variables in URL? I need it for my custom table derived from WP_List_Table, where I construct links to filter according to terms.
For example,...
0
votes
0
answers
133
views
JetEngine Query Builder - order by value from repeater
Using Wordpress JetEngine UI. I have:
a JetEngine Post Type named "Stores"
it has a meta field nearby-cities (repeater)
each nearby-cities entry has city-name and distance repeater fields
I ...
1
vote
1
answer
118
views
Why is variable not working on custom sql query using wpdb?
Im trying to insert bulk post meta in a single query, however when it wont insert data if i use variable on it.
Here are my codes so far.
I added comments on which codes work & which does not.
(...
0
votes
0
answers
20
views
Change pure SQL database query to WordPress post query?
I am trying to query posts that are nearby a given (lat/long) location. I have found this working SQL query, but this won't provide me flexibility to alter the queried later on, since I am not really ...
0
votes
0
answers
18
views
Change SQL get_results to search for posts with custom term in custom taxonomy
I am using a SQL database query to get posts that are nearby a given location. I also extended this script so that people can search for posts with a certain name. Now I would like to extent it so ...
0
votes
0
answers
20
views
Change language on website and change currency with url query
I got plugins that change language automatically, such as loco translate and Gtranslate. I need help when the user changes language also the currency
if someone chooses the Spanish language then the ...
0
votes
0
answers
43
views
Merge CPT Taxonomy and Post Taxonomy in $query->set
I'm merging blog posts and a custom post type into a single query and displaying them on my feed as well, here's the code:
function add_query_news_projects( $query ) {
if ( is_home() && $...
0
votes
1
answer
29
views
Wordpress Query - Display 5 posts (same post type), each from a given tag
We have a news section on our website. We have basically 5 companies giving publications:
('ENEFI', 'dmker', 'megakran', 'otp', 'futuraqua')
We would like to list the latest one from each and order ...
0
votes
0
answers
18
views
Sort a list of a CPT ( job) if a meta is empty
I would like sort a listing if the CPT has the meta field video_link is empty.
I use Elementor and Jet engine.
If you have an idea
Thanks
1
vote
2
answers
49
views
Create ONE callback for all page templates, post filter queries + paginated pages, triggering pagination via AJAX
I'm querying posts using the following wp query:
function custom_retrieve_posts_function() {
$paged = get_query_var( "paged" ) ? get_query_var( "paged" ) : 1;
$args = array(
...
0
votes
0
answers
27
views
Update query based on CPT / Post Type, show all sorted by date
I'm trying to accomplish something similar and read through Vayu's code, which is super elegant, but it doesn't accomplish what I need.
Specifically, I need to be able to include a different template ...
0
votes
1
answer
218
views
How can I check that the acf field value is not a duplicate when adding a post?
I have a field in which I add the name of the record in the original language. And I translate the title into another language. When adding a new record, I need to check this field for duplication in ...
0
votes
1
answer
20
views
Query filter by value in meta_value array
I try to add a filter to make an elementor post widget displays the posts depending on a certain custom field.
The custom field key is adress and contains an array with some keys like street_number, ...
0
votes
0
answers
21
views
Change search query in wordpress custom post type
I want to change the query of search a custom post type in wordpress admin panel. I use this method:
function change_admin_search( $query ) {
$post_type = 'custom_post_type';
if( ! is_admin()...
0
votes
0
answers
26
views
How to delete all images from code in all post_content
In the past I occationally used this sql query to update links in post_content:
update wp_posts set post_content = replace(post_content,'domain.org/Maries','maries.no');
I wonder if I could use a ...