Skip to main content

Questions tagged [query-posts]

Set up The Loop with query parameters. This will override the current WordPress Loop and shouldn’t be used more than once. This must not be used within the WordPress Loop.

Filter by
Sorted by
Tagged with
0 votes
1 answer
18 views

Adding a language rule and displaying posts with a custom taxonomy term on its archive page

The WordPress website I'm working on is available in two languages using Polylang, en-US and en-PH. I use CPT UI and have a custom taxonomy "subtopic" that is not multilingual. Under "...
Sum's user avatar
  • 11
0 votes
1 answer
19 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 &...
Roniery Rêgo's user avatar
0 votes
0 answers
41 views

How can I filter Query Loop to show only posts in current category?

I am migrating a site from a page builder to a block theme. In my main post template I want to list other posts in the same category as the current post, excluding the current post itself. In the page ...
J Glasshalfpool's user avatar
0 votes
1 answer
43 views

How do I access the current post object within a block theme template or pattern?

How should I be able to query things like specific metadata or any other thing from the post object? Apparently I don't have access to basic functions like get_the_ID() or similar functions inside ...
thebigJ's user avatar
1 vote
1 answer
51 views

Randomize post list with some posts with specific ACF value in the top 50%

I'm using a plugin that lets me order posts and set some as "sticky" and always on top. I have the example code below that will randomize all posts except for the sticky posts, they will ...
dagnabbit's user avatar
0 votes
1 answer
18 views

post per page for differents post types in a same query

How can I make a query and in the same query query many types of publications and also define the number of publications for each one.? This is what I have in my query $post_types = array('infografias'...
Peter Alexander's user avatar
0 votes
1 answer
895 views

get_the_ID() retrieves same ID on Gutenberg's Query Loop

I'm using Gutenberg editor and I want to add a shortcode (using XYZ PHP Code) that uses the post id to retrieve certain ACF value. I'm editing the home page where the last blog posts are shown, but I ...
Alvaro's user avatar
  • 131
0 votes
1 answer
165 views

get posts from Rest Api by meta_key/meta_value not working

I have a function that fetches all the latest posts which works fine. But i wish to fetch only the posts that have a specific value from a custom option. But adding the meta_key/meta_value does not ...
Christophe's user avatar
0 votes
2 answers
238 views

Exclude first post from wp query

I am building a WordPress website and I want to show post in it. But the problem is that, I want to exclude the first post in query. I have not much knowledge of PHP. So please help me to de this. ...
Ahmed Muneeb's user avatar
0 votes
1 answer
52 views

new WP_Query with order args – no more distinction between categories

I try to change the post order on all of my category/archive pages from the WP standard to having them sorted by their modified date. I modified a part of the loop.php from my theme (derived from ...
Frank Wagner's user avatar
0 votes
1 answer
304 views

How to change url of posts?

I want to show my posts url like "domain.in/blogs/blogname" . for only the posts not for the pages. how can i make it like that
spidy223's user avatar
0 votes
1 answer
37 views

How do I exclude the current post from the upcoming post query

Summary: I have a page template with 3 queries. Current Exhibition Upcoming Exhibition Past Exhibition The dates are custom fields. The problem I'm having is, how do I dynamically exclude the ...
Chris Brennan's user avatar
0 votes
0 answers
35 views

Trying to set up a range filter for related custom post types

I have set up two CPTs, "Property" and "Suite". Each Property has a number of Suites assigned to it via an ACF bidirectional relationship.  Each suite has a set size (in square ...
Jon Timms's user avatar
0 votes
1 answer
116 views

Count words for all posts by all authors

So I got this code from another query and it works for one single post. However, I want to show the total words of all the published posts by all authors. How do I modify this or is there a wp ...
Elaine Byene's user avatar
0 votes
1 answer
533 views

Display ACF object field data using Elementor Custom Query

Hello i'm working on a website using elementor pro + ACF. I have create a custom post type (CPT1) with ACF object field that take another CPT2 as values. I would like to display on my CPT1 page all ...
AKEAmazan's user avatar
0 votes
0 answers
125 views

Optimising WP_Query with ACF Fields

I am wondering if it's still possible to optimise the WP_Query or also if there's another way of doing it. I have the post type and a custom post type called case-study which gets displayed on the ...
Erick T's user avatar
0 votes
1 answer
24 views

change the default order of posts only for specific categories

I want to change the default ordering for posts, to last modified date, but only for certain categories pages (when visiting certain category pages) I have this function code, which is working, but I ...
vyperlook's user avatar
  • 177
0 votes
0 answers
717 views

Elementor posts custom query based on tag [closed]

How can I filter the Elementor Posts widget with a custom php query that returns posts with a specific tag attached? I want to do something similar to this: function my_query_by_post_types( $query ) { ...
ChristosDg's user avatar
0 votes
0 answers
272 views

Custom Query: Multiple CPTs and a taxonomy filter

I want to create a post feed that displays the following: ALL posts in the CPT 'custom_post_type_1' Any 'post's in the category 'speakers' So far, I have this filter which displays all posts in '...
srack's user avatar
  • 1
1 vote
0 answers
208 views

Query post and sort by custom value calculated with custom field on cpt

I shall made a query post ad I have some issue to sort the posts. I have multiple custom fields that calculated in php (with some operators) a final value for each posts - I call it $price. These ...
James's user avatar
  • 11
0 votes
1 answer
119 views

How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]

I am using ACF Pro to make a relationship between two custom post types. One CPT is a thing and the other is a Container of Things. I need to solve the issue of things within a container of things ...
Jordan W.'s user avatar
0 votes
0 answers
59 views

WP query_posts group by meta field related

Hello Guys i am trying to customize a wordpress theme and am getting this is How it queries All Posts with episodes post_type. My Question Is. this Post type is related to another post_type which is ...
Tristan Morris's user avatar
0 votes
1 answer
123 views

Conditional operator OR not working with custom fields

OR operator is not working for both conditions, only check first value if true then code executed and if first is false then not check 2nd condition and return else output. I also try with LIKE ...
Puneet's user avatar
  • 47
0 votes
1 answer
160 views

complex get_posts() query to select child pages

I have pages on 2 levels under the main deparments page like below. Departments --Department 1 -----Course 1 -----Course 2 --Department 1 -----Course 3 -----Course 4 --Department 3 --Department ...
LeeTee's user avatar
  • 31
1 vote
0 answers
33 views

How can I create 'future' and 'past' parameter for restAPI by filtering the CPT custom date field by greater than / less than current datetime?

add_filter( 'rest_events_query', 'filter_events_by_date_field', 999, 2 ); function filter_events_by_date_field( $args, $request ) { if ( ! isset( $request['filter_date'] ) ) { return $args; } $...
Abi's user avatar
  • 11
0 votes
0 answers
169 views

search.php to search only the post title

I'm trying to rewrite my search.php to search only for the post titles because I have a ton of posts published to my site (around 400k), which slows down the search speed to about 20s per search. <?...
Dardan Asllani's user avatar
0 votes
1 answer
545 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&...
John Dee's user avatar
  • 503
0 votes
0 answers
69 views

Hot to check if new posts have been published since page load and notify online users?

I want to show a div notifying online users that there are new posts since they have accessed the page, in the index and also if new posts have been added in the category or tag they are browsing. I ...
Carlos B's user avatar
0 votes
1 answer
110 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 ...
Teymur Abbasov's user avatar
0 votes
1 answer
387 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 ...
Fernando Redondo's user avatar
0 votes
0 answers
186 views

Sticky posts limit query and pagination for a custom post type

I would like to display 9 posts per page. But, when I have a sticky post, I would like it to be integrated in the 9 posts in the query. And, then, for the second page, I continue to have the next 9 ...
Gpi's user avatar
  • 111
1 vote
0 answers
69 views

Serve specific "template" page at any URL that ends in its slug

Still new to WordPress, so please go easy on me. Goal: Prevent users of a specific role from viewing other custom post types made by users of same role. Intended solution: Modify the URL and redirect ...
Ryan Cochran's user avatar
0 votes
2 answers
137 views

Move position in post list for a custom checkbox column

I have made checkboxes to every post in post list. Question: How can I change the the position for the new column. Now it`s at the right side of the post list. After "Date". How can I move ...
bjovaar's user avatar
  • 21
0 votes
0 answers
66 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 ...
RobbTe's user avatar
  • 242
-1 votes
1 answer
498 views

Wordpress pagination returns the same posts

I did search the other posts here related to this problem, and tried all of them in my case, but I can't seem to make it work (probably because I don't know enough code) Can you please help me with ...
vyperlook's user avatar
  • 177
0 votes
0 answers
57 views

Counting post and changing roles in mysql database. Query not code

Hello I'm struggling to find an answer talking specifically about counting post and changing roles but on mysql language not php in the wordpress source. I'm not creating a plugin neither I want to ...
gallo2000sv's user avatar
0 votes
1 answer
139 views

Why does my WP_Query pagination on a custom page.php only loads the homepage?

What I am looking to do: Setup WP_Query pagination in a custom php template file with a custom WP_Query query (It's not originally mine, I'm just fixing it). The file loops through posts (category &...
Lisa's user avatar
  • 13
0 votes
0 answers
47 views

Query post ordered by meta value that show first post that contained a tag

I have a query post for my CPT 'listing' that order posts by value of price contained on meta key. Now I'd like to add the possibility to show in the loop first posts that has a specific tag (o ...
Giulio's user avatar
  • 51
0 votes
0 answers
127 views

Facing problem with tax_query results

I need to get search results for posts on the basis of post-category(must) and posts-tags(optional). The process is like: search for a string e.g. "bananas" the category is always static ...
Majid A.'s user avatar
0 votes
0 answers
103 views

How do i create a custom post query when the meta value is an array?

A number of properties have been imported from an external API and saved into a custom post type called 'Properties'. I want to filter these properties by the city they are located in, however it is ...
Zeus7's user avatar
  • 1
0 votes
0 answers
542 views

Custom post type archive page filters

What is the proper way to filter my custom post type archive page by my custom taxonomies? When i go to archive page(archive-recipies.php), fetch me all the post under the custom post type. In this ...
Tsourou Nas's user avatar
0 votes
1 answer
110 views

Get posts that do not have the same tags as current

I'm trying to get all posts in a custom plugin loop that DO NOT share the same tag as the current one. I'm trying: $events = tribe_get_events([ 'start_date' => 'now', 'eventDisplay' =&...
Eli Nathan's user avatar
0 votes
1 answer
176 views

Get a Post Loop based on Logged in User information into a Shortcode

I have a follower button on users profiles where users can follow other users. I have a page template that shows all posts by users the currently logged in user follows. I would like to create a ...
RobH's user avatar
  • 7
0 votes
1 answer
118 views

How to obtain the recent posts without their content in an efficient way?

It would be great to make a single DB request but I don't know how to do that either. I have this code and it works but I want to change it to be more efficient: $cs = get_categories(array( '...
silviubogan's user avatar
1 vote
0 answers
62 views

Set multiple Post Terms in same Taxonomy

I'm having a hard time trying to figure out this problem. I have looked at various StackExchange threads but nothing seems to work. Long story short. I have a custom table that updates every day which ...
Giacomo Gaglione's user avatar
0 votes
0 answers
296 views

WordPress create custom XML RSS feed template

I am trying to create a custom XML RSS feed. However, my code is not quite working as expected. Here is what I have done: In functions.php I have created the feed called "top": add_action('...
TurboTobias's user avatar
0 votes
0 answers
130 views

Global $post returns 2 objects for my shortcode

I made a shortcode, it does most of what I need it to do. Except for a filter I need the post id of the page the shortcode is placed. (to get some linked custom field values) And I can't expect the ...
marty90's user avatar
  • 11
5 votes
1 answer
4k views

WP 5.8 "Query Loop" block: where to place custom query?

In the recent wordpress.org article outlining the new Query Loop block, it says the "Inherit query from template" option allows you to "customize the query that the loop relies upon ... ...
Rickmakeitquick's user avatar
1 vote
1 answer
946 views

Query with a meta value inside a given range

Quick question: I would like to retrieve some pages/posts with a meta value inside a range, eg) $min<$meta_value<$max for ordinary $meta_value there was a way to get pages/posts like this: $args ...
Martin Spinoza's user avatar
0 votes
1 answer
439 views

Show posts from two specific category in WP_Query

I've two category employee and full-time. If a post publish in both (employee and full-time) category then the post will show in his specific section. If post has only employee category, not full-time ...
user avatar

1
2 3 4 5
25