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.
1,251 questions
2votes
3answers
111views
How to change WP Query to display related posts
I am creating a WP block theme and want to show related posts on the single post page. Using the Query Loop block, I have added a new pattern that displays the latest posts. Now I want to change the ...
0votes
1answer
101views
How to get posts in the exact quantity in default WP query via query_posts?
I tried to manipulate the default WP query to avoid problems with the pagination. I need to get the posts in specific quantity, regardless of max number of posts per page. I want to be able to choose ...
1vote
1answer
105views
Using Nested Blocks With Custom Query Block
I'm experimenting with a custom query block for the fun of it. I would like to leverage the components that come with core query inner blocks (title, excerpt, featured image, etc..). For this test, I'...
0votes
0answers
24views
Wordpress Post Query Using Custom native MySQL like St_Distance_Sphere
Is there a way to query posts for "the loop". But include some filter on the results based on a mySQL Function like St_Distance_Sphere? Or convert a wpdb->query into a form similar to &...
1vote
2answers
19views
Category Attachment Pagination 404 Error on 2nd Page
I'm customizing category.php to display all attachments with a specific category, but when I click on a link for a page besides the first one, I get a 404 error. To reproduce: Install a new Wordpress ...
0votes
0answers
65views
Block Theme : Query Loop with attachments
I am new to wordpress development. These day I am trying to create my own block theme in wordpress. In my theme, I have added two file upload fields to default wordpress posts using ACF pluign. It is ...
1vote
1answer
46views
Why does 'get_the_ID' work outside of the loop?
on WordPress Developer Resources website's page related to get_the_ID() function it says: Retrieves the ID of the current item in the WordPress Loop But I can use it outside of the loop and it works ...
0votes
1answer
53views
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 "...
0votes
1answer
200views
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 &...
1vote
1answer
190views
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 ...
0votes
1answer
132views
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 ...
1vote
1answer
59views
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 ...
0votes
1answer
23views
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'...
0votes
1answer
2kviews
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 ...
0votes
1answer
376views
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 ...