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
0answers
18 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 ...
0
votes
0answers
6 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 ...
0
votes
0answers
23 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 ...
0
votes
0answers
33 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 ...
0
votes
0answers
36 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 ...
0
votes
1answer
29 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' =&...
0
votes
1answer
26 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 ...
0
votes
0answers
20 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 ...
0
votes
1answer
52 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( '...
1
vote
0answers
20 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 ...
0
votes
0answers
22 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( ...
0
votes
0answers
18 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('...
0
votes
0answers
27 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 ...
0
votes
0answers
13 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 ...
3
votes
1answer
433 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 ... ...
1
vote
1answer
29 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 ...
0
votes
1answer
45 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 ...
0
votes
1answer
37 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 ...
0
votes
0answers
33 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, ...
0
votes
1answer
26 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 ...
0
votes
0answers
33 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 ...
0
votes
2answers
52 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'...
0
votes
1answer
51 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'...
0
votes
1answer
19 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 ...
0
votes
1answer
21 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 ...
0
votes
1answer
34 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 ...
0
votes
2answers
53 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 ...
0
votes
0answers
111 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 ...
0
votes
1answer
118 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('...
0
votes
0answers
43 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 ...
0
votes
1answer
14 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 &...
0
votes
1answer
23 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 ...
1
vote
1answer
149 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", "...
0
votes
0answers
32 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 ...
0
votes
1answer
265 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 ...
0
votes
0answers
40 views

Updating post count on admin page after pre_get_posts filter

After the pre_get_post filters out the past posts, the number of posts above the page is still the original count of all posts (custom post types). How can I update that number so it'll correspond ...
0
votes
0answers
18 views

How to get max value of filtered query post

I have a query post to filter my post in my CPT, filtered on front end by a form filter. The problem is that with different filter, I have different max value. For example I have the following custom ...
0
votes
0answers
16 views

How to create loop of posts except post ID defined via ACF field

I am creating a custom news page with two columns - 1st column - featured post - using a ACF text field to add post ID to show, ie: 12345 - works fine. 2nd column - remaining news, showing all other ...
0
votes
0answers
18 views

Allow users to subscribe to posts submitted by a specific user and/or user group and display those posts in posts index feed

I have a WP project that requires a complex set up. I'm trying to set up my WP site to allow Company Profiles which are basically user groups. In the group users that belong to that group will be able ...
0
votes
0answers
71 views

Duplice post with standard WP loop - fixed by using query_posts() instead

I have an index.php file on a website designated as the blog page. I have an archive.php file which handles all the subsequent category pages. I ran into an issue on the archive page, where for one of ...
0
votes
3answers
26 views

How can I show only 5 posts from the relationship?

HI I use plugin: Advanced Custom Fields How can I show only 5 posts from the relationship? This is the code: <?php $c_lists = get_field( 'c_lists' ); ?> <?php if ( $c_lists ) : ?> <?...
0
votes
1answer
52 views

find custom post type post by searching its custom field with my string

I have a custom post type called series and each post has a custom field named originaltitle. So in my code before I create a new post, I need to check if there is already a "series" with ...
1
vote
1answer
24 views

Fetch Record based on meta key dates

I want to write a query which fetches the data based on my meta key added. Meta key name is 'repeater'. This is my POST META. Serialized: a:3:{i:0;a:3:{s:9:"postdates";s:10:"2021-02-02&...
0
votes
0answers
74 views

ElasticPress is (aparently) messing with my search filters

I recently installed ElasticPress on my woocommerce store, and it's working fine -- the product page is showing normally, and the search bar is working fine with the new elastic capabilities. However, ...
1
vote
1answer
17 views

Show Only Posts Owned By Logged In User + my post

I would like to restrict access for logged in users to specific posts: their own posts and my posts (as they will serve as templates for them). I find this code snippet that works perfectly to show ...
0
votes
0answers
13 views

how to display posts of events that recur each year

im not sure if this has been asked before if it has then please direct me to the appropriate post i have created posts for events that come up on fixed dates every year . so for example i have a ...
1
vote
0answers
14 views

How to display multiple custom fields with the same meta_key in an ascending order?

I am using query_posts to display a list of custom fields from some posts on my WordPress site. Each post has at least one custom field called showcase. In some cases, there are two showcase entries. ...
0
votes
0answers
15 views

Display custom type posts instead another custom type posts

I develope my WP site so I have 2 custom post types "cases" and "newcases". The "newcases" posts have new design and content. So I have more than 500 "cases" ...
0
votes
1answer
298 views

FacetWP paging custom wp_query

firstly the overview of what I'm trying to achieve. I'm building a resource center which lists out various custom post types and it's filterable/searchable thanks to FacetWP. Within this listing of ...
0
votes
1answer
16 views

Help with query_posts function

I have a paid theme that has the following function manually hard-coded. It pulls the 8 latest posts and displays them: global $do_not_duplicate; global $post; query_posts( array( 'posts_per_page'...

1
2 3 4 5
25