2022 Developer Survey is open! Take survey.

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
0 answers
11 views

Trying to create a Video News Page, that contains only the video and the title of the post that it was first uploaded to [closed]

I'm trying to create a new Page that contains only Videos, which are first uploaded inside a post that also contains some text and a title, which title I want to use to represent that particular Video....
user avatar
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&...
user avatar
  • 455
0 votes
0 answers
24 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 ...
user avatar
0 votes
0 answers
20 views

Pull in posts using post meta for REST API

So I wasn't able to find much detail about this, so I wanted to ask the community to see if I can get an answer. So let's say that I have the following: $this->global_endpoint = 'https://example....
user avatar
  • 1
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 ...
user avatar
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 ...
user avatar
0 votes
0 answers
34 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 ...
user avatar
  • 1
0 votes
0 answers
15 views

Custom wp-query display post only today

I have a problem. My query not display the post only today. $today = getdate(); $query = new WP_Query( array( 'post_type' => 'tips', 'posts_per_page' => '9', 'order' ...
user avatar
1 vote
0 answers
26 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 ...
user avatar
0 votes
2 answers
34 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 ...
user avatar
  • 21
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 ...
user avatar
  • 230
-1 votes
1 answer
37 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 ...
user avatar
  • 165
0 votes
0 answers
24 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 ...
user avatar
0 votes
1 answer
33 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 &...
user avatar
  • 1
0 votes
0 answers
43 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 ...
user avatar
  • 51
0 votes
0 answers
32 views

How to merge the content of posts that have the same title?

Good evening everyone... I apologize in advance for my bad English, for any complaints go to google translate :). I need to merge posts with the same title and I don't know how to do it. The situation ...
user avatar
0 votes
0 answers
10 views

Different post slug based on archive

I need some help with my current WordPress site. The site got 6 post categories. Posts can have multiple of these categories. The slug of the posts include the category slug. For each of the ...
user avatar
  • 1
0 votes
0 answers
33 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 ...
user avatar
0 votes
0 answers
40 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 ...
user avatar
  • 1
0 votes
0 answers
106 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 ...
user avatar
0 votes
1 answer
41 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' =&...
user avatar
0 votes
1 answer
35 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 ...
user avatar
  • 7
0 votes
0 answers
21 views

get posts, run a custom query, and join the results

I need to get the posts, and then run a custom query (getting posts too, but joined table with several custom tables, to modify the posts sql where is not useful here) and return an array with the ...
user avatar
  • 1
0 votes
1 answer
70 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( '...
user avatar
1 vote
0 answers
22 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 ...
user avatar
0 votes
0 answers
27 views

Need to add a space after meta value in query_posts in wordpress for zipcode search

query_posts on wordpress has been trimming the last space of meta value added. on my case I need to add a space after zip code on the meta query $meta_query[] = array( ...
user avatar
  • 1
0 votes
0 answers
24 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('...
user avatar
0 votes
0 answers
42 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 ...
user avatar
  • 11
0 votes
0 answers
16 views

Users Query Permalink to Post URL

Using Elementor. I have a question, displaying users by roles (subscriber) on page with different user meta fields like image, username and button. Subscribers can add 1 property listing. Now I want ...
user avatar
3 votes
1 answer
1k 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 ... ...
user avatar
1 vote
1 answer
52 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 ...
user avatar
0 votes
1 answer
63 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
0 votes
1 answer
130 views

Filling custom post type posts from a rest api

I have been trying different wordpress intermediate challenges, I came across one today that brought up a question I had no idea how to resolve it requires displaying data from a rest api however the ...
user avatar
  • 101
0 votes
0 answers
34 views

Getting Wordpress to output links in random from specific category (random every refresh)

Trying to get Wordpress to output 5 random links from a specific category (in this example "158" is the category ID. My code below generates 5 links from the correct category as I want them, ...
user avatar
0 votes
1 answer
32 views

How to query for all posts that have a particular meta key?

I have many posts. Some have meta data, with a key called "foo". How can I query for just the posts with the meta data "foo"? metadata_exists requires the post ID, I'm trying to ...
user avatar
  • 455
0 votes
0 answers
120 views

Elementor custom query get all terms - Custom taxonomy in Post Types product

I try to perform a custom query, but without success. In the post type of products I created taxonomy - designers I need to create a query that will show me all terms- designers. Thanks for the ...
user avatar
0 votes
2 answers
97 views

How to check in functions.php if there is data in a WP_Query?

I have 2 different WP Query on the home page. I need to check $home_query condition in functions.php then I want to do something if $home_query returns null. I tried with pre_get_posts action I couldn'...
user avatar
  • 3
0 votes
1 answer
71 views

Shortcode with 'year' parameter

I would like to display posts with a 'year' parameter. For example: to display posts from 2020, the shortcode should look like [archived-posts year="2020"]. I have tried my code below but it'...
user avatar
  • 129
0 votes
1 answer
20 views

How do widgets access posts they should display?

How do widgets embedded in a page access posts they should display? How do widgets (php code) in the page access the posts they should display (via the used template's post loop / with wp_query and ...
user avatar
0 votes
1 answer
25 views

Does Wordpress run a post query when a page is invoked?

Let's say I create a what in the Wordpress backend is called a page (pages - new page). I put some arbitrary page elements on it (e.g. title, text, some images, a widget or two displaying posts from ...
user avatar
0 votes
1 answer
110 views

How does post loop integrate individual page elements

I am just trying to understand how coding in Wordpress works. I have read a bunch of tutorials about post loops and how to modify them with queries, but I have no idea how individual page content I ...
user avatar
0 votes
2 answers
79 views

how to load random related posts with specific custom fields?

I want to load 3 posts that have the same custom field value as the current post. for example: The current post has 3 custom fields: color: black background: red lastname: doe Now I want to load ...
user avatar
  • 147
0 votes
0 answers
153 views

Tax query get first product with attribute value in pre_get_posts

We've got a webshop with over 3000 products. Some products have the same attribute value for pa_model, as shown below. Productid 1 - pa_model Nike Productid 2 - pa_model Nike Productid 3 - pa_model ...
user avatar
  • 9
0 votes
1 answer
396 views

Pagination not working on custom query on a page

I have a custom query on a page (it is not an archive page), it works just fine, but I want pagination and it is not working at all... <?php $paged = (get_query_var('...
user avatar
0 votes
0 answers
95 views

custom post type and a "sticky" position taxonomy

I have a custom post type with a custom taxonomy that denotes various types of places the custom post might appear in the site. One that I'm having some trouble with is a "sticky" term for ...
user avatar
  • 472
0 votes
1 answer
16 views

Loop through posts of only 2 statuses

Setting up a visibility condition for a widget - i need it to apply to the posts in a certain term but only those of "pending" and "publish" status. this essentially hides the &...
user avatar
  • 7
0 votes
1 answer
26 views

Targeting custom post type via functions.php doesn't work

I have a custom post type, books, set up and a custom taxonomy, book_cat, to act as categories for these posts. I've added the below code to functions.php to sort posts on my custom taxonomy archive ...
user avatar
1 vote
1 answer
372 views

WP Pagination on Posts Search Results Page resulting from AJAX WP Query

I have a simple WP post query, which is supposed to load 8 posts per page, with a post navigation displayed below, like so: $query_args = [ "post_type" => "post", "...
user avatar
  • 286
0 votes
0 answers
42 views

query hook parse_tax_query function takes no effect

I'm trying to build a function (inside a plugin), which limits the shown posts to the time a logged in user is registered in weeks. (So if a user is registered for 4 weeks the categories page shoud ...
user avatar
0 votes
1 answer
525 views

Wordpress sorting posts by date and title using a dropdown

I'm trying to set up a dropdown that would sort my posts by Newest to oldest and Alphabetical. This is what I have so far: I'm declaring an empty variable, then a form where I can change the contents ...
user avatar

1
2 3 4 5
25