Questions tagged [query]

A generic term referring to the process of retrieving information from a database.

Filter by
Sorted by
Tagged with
0 votes
0 answers
14 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 ...
Peter Cooper's user avatar
0 votes
1 answer
8 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 ...
user18102663's user avatar
0 votes
2 answers
28 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 ...
Aristocles's user avatar
0 votes
1 answer
12 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 ...
hugogogo's user avatar
  • 111
0 votes
0 answers
15 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/...
wepli23's user avatar
1 vote
1 answer
43 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: ...
Rain Man's user avatar
  • 154
0 votes
1 answer
32 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 ...
Badger's user avatar
  • 193
0 votes
0 answers
27 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 ...
Ava Northon's user avatar
0 votes
1 answer
31 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 ...
Beep's user avatar
  • 29
0 votes
1 answer
72 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'...
JDQ's user avatar
  • 149
0 votes
1 answer
38 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. ...
Systemedic's user avatar
0 votes
0 answers
29 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 ...
Sum's user avatar
  • 11
1 vote
1 answer
58 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 "...
Displayname71's user avatar
0 votes
0 answers
142 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" ...
Maseres's user avatar
0 votes
1 answer
43 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 ...
user2402492's user avatar
0 votes
1 answer
61 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 ...
lastnoob's user avatar
  • 153
0 votes
1 answer
25 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( ...
t0mii's user avatar
  • 3
0 votes
0 answers
49 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 ...
post poop zoomies's user avatar
0 votes
0 answers
15 views

How do you create a query to hide all posts with a certain meta key, unless current user is the author of that post, without custom SQL?

The scenario, which I would have thought is quite common, could be where a blog post has been assigned a particular meta, and should be removed from public display, apart from the original author who ...
Ben Roberts's user avatar
0 votes
0 answers
29 views

How to cache results of of get_available_post_statuses() function as it is causing a slow query on a website with over 1 million posts?

The function get_available_post_statuses() is being called by WP_Posts_List_Table->prepare_items(), which is calculating posts on each load of admin. Since this is a core wordpress function and I ...
dc09's user avatar
  • 195
2 votes
0 answers
67 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 ...
Poorya Ghorbani's user avatar
0 votes
0 answers
49 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 ...
user1462's user avatar
  • 1,284
0 votes
0 answers
8 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`; // ...
Simon H's user avatar
  • 335
0 votes
0 answers
31 views

old content are still displaying after using wp reset and clear cache

i have only two files in public_html folder, but when i opened the website link in private window, site old content is still displaying ? what i need to do to remove old site content ? index.php : ...
firstchoice entertainments's user avatar
0 votes
0 answers
9 views

How to query by subcategory and, if there are fewer than 10 posts in that subcategory, fill out with posts from parent category

I want to query all posts by subcategory and, if there are less than 10 posts in that subcategory, I want to return posts from the parent. If there are still not 10 posts, I want to fill out the ...
user18102663's user avatar
0 votes
0 answers
23 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 ...
Francisco's user avatar
0 votes
0 answers
94 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 ...
Marko's user avatar
  • 1
0 votes
0 answers
15 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 ...
gooloode's user avatar
0 votes
0 answers
23 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 ...
Gianni Fazio's user avatar
0 votes
0 answers
207 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 ...
Tryandcry's user avatar
0 votes
2 answers
282 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( $...
Motivated's user avatar
  • 205
0 votes
0 answers
16 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 ...
Lisa's user avatar
  • 13
0 votes
1 answer
32 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 ...
milenmk's user avatar
  • 113
0 votes
0 answers
29 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() { ...
Pete's user avatar
  • 998
0 votes
0 answers
31 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( ...
Petar Vasilev's user avatar
0 votes
0 answers
50 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 ...
Emma's user avatar
  • 11
0 votes
0 answers
20 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($...
shinzo vender's user avatar
0 votes
0 answers
48 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 ...
Emma's user avatar
  • 11
0 votes
0 answers
20 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 ...
TechyDude's user avatar
  • 125
0 votes
1 answer
154 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 ...
Stefan's user avatar
  • 1
0 votes
0 answers
166 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 ...
Graeme Bryson's user avatar
0 votes
1 answer
246 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?
Marc P's user avatar
  • 513
0 votes
1 answer
290 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 ...
phenomenia's user avatar
0 votes
0 answers
20 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.
Csopso's user avatar
  • 1
0 votes
0 answers
96 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 ...
Marzii's user avatar
  • 23
0 votes
1 answer
531 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 ...
Peter Ajtai's user avatar
0 votes
1 answer
127 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"); $...
Jonas's user avatar
  • 159
0 votes
1 answer
52 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. ...
Mike's user avatar
  • 111
1 vote
1 answer
445 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 ...
Jesper's user avatar
  • 11
0 votes
0 answers
691 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 ...
moorewebx's user avatar

1
2 3 4 5
38