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
-2
votes
0answers
13 views

WP_Query->get_posts() [closed]

I used the Query Monitor plugin to find slow query on my WordPress site. The below-mentioned WP_Query->get_posts() takes about 18.6200 query time out of the total Database Query time of 19.6249. ...
0
votes
0answers
19 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
11 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
15 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
69 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
24 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
31 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
21 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
31 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
11 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
0answers
136 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
15 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'...
0
votes
0answers
13 views

“Post List” Loop containing other “Child Post List” loops causes pagination error ELEMENTOR

I am using a loop template to display posts in a custom template. The loop template contains another loop to display a list child posts. Child post list requires paginaion, but I am encountering a bug ...
0
votes
0answers
18 views

Wordpress primitive query returns = array

i am trying to primitive query form this wp_query: $query_v = array( 'post_type' => array('pro'), 'posts_per_page' => -1, 'orderby' => $count_visit, 'order' => 'ASC', ...
0
votes
1answer
16 views

Displaying all posts from other sites on the network on one site

I have a multi-site setup as follows Main Site has no posts Site A has 1 post A Site B has 1 post B Site C has 1 post C What I'm interested in is to be able to treat the main site as an aggregation ...
0
votes
0answers
12 views

How can I list all posts on a given day of the year (Month, Day, but _any_ year)?

Is there any way to show all the posts on a particular date for any year? WP has built-in support for a /yyyy/mm/dd/ path which will show an archive [I believe that's what it's called?] page for all ...
0
votes
1answer
26 views

Create a post automatically if search result has zero results

I'm developing a site where people can search phone number(s), the most complex part is that i want to create a post automatically when someone search for a specific number if that phone number yield ...
0
votes
1answer
21 views

Trying to list years (for a filter) but not all years display

I did an ajax filter to filter posts per years, however the filter isn't showing all items. Years are displayed in DESC order, but not all years appear I don't understand.... <?php $terms_year = ...
0
votes
0answers
14 views

Is there anyway I can call the year once?

Hi everyone I hope you have a great day, I was wondering if is there anyway I can call the year once?. I really don't know if its possible to call the date once cause mine keeps on repeating calling ...
0
votes
1answer
22 views

Getting post URL within custom content template

This should be such an easy thing but it's giving me so much headache. I created a content template called content-sticky.php. Added all the code there <article id="post-<?php the_ID(); ?&...
0
votes
0answers
39 views

custom post type get_posts() function not work

$orders = get_posts(array( 'post_type' => 'lp_order', )); foreach ($orders as $order) { // get all order data code } This the code I will try to learnpress plugin order post type front end ...
0
votes
0answers
21 views

How to fetch courses in all languages in WordPress?

I have a query which fetches English courses only. How can I fetch all the languages courses? I am using WooCommrce with LearnDash. public static function list_courses() { global $post; ...
1
vote
1answer
85 views

Can't search posts using WP_QUERY inside AJAX Function

WP_Query is used to get posts via simple arguments provided by it. WordPress provides an argument called 's' for search. It basically searches content of all posts and lists the ones with that string ...
0
votes
0answers
25 views

How to display only 1 post of many child-categories in the Parent Category page of Woocommerce

I am trying to display only one product of a child category in the page of parent category. If I use $query->set( 'posts_per_page', '1' ); it shows only only 1 post , which is near to what i want ...
2
votes
1answer
25 views

How do you query wordpress posts using a math formula between multiple meta field values?

The following scenario is entirely fictitious, but it illustrates what I'm working on perfectly. Imagine that you have a school syllabus set up in WordPress. The students can turn in assignments early ...
1
vote
1answer
174 views

Slow WP_query due to nested wp_query. Need Suggestions

I'm facing an issue of slow queries. As I'm not that familiar with the WP_query, I managed to solve my problem with nested wp_query. https://it.zoetalentsolutions.com/technology-provider/aws/ in the ...
0
votes
0answers
25 views

Filter search results by post_tag if exist

I want to get posts from search results using post_tag. for example If a user input in the search form "party". First, we search if "party" exists in post_tag and show all posts ...
0
votes
1answer
34 views

How do I change the default sort order of a custom column on the posts page?

I have a fancy custom column on the posts page in the WordPress admin. I have this column set up to be sortable. The first time that you click on the column header, the URL in the address bar changes ...
0
votes
1answer
106 views

custom post type and user post count shortcode

Hello i m a newbie in php and Wordpress development. I was struggling to get a user custom post count in my wordpress/buddypress site frontend. i m using this code: // add [author-post-count] ...
0
votes
1answer
63 views

pre_user_query vs pre_get_posts

I've used pre_user_query to edit the actual sql query and it works wonderfully. Now I'm trying to work with pre_get_posts and its not at all the same thing. I need to do an INNER JOIN.. In this ...
0
votes
0answers
20 views

Creating custom Wordpress query with multiple taxonomies

I have a custom post type of "the-talent" and 3 custom taxonomies (level, location, and specialty). I'm trying to figure out how to write a custom query for "the-talent" post type ...
0
votes
0answers
18 views

WP_Query show the posts in sequence of tags entered in Query

Basicly I want to show the post in sequence of what the tags entered are. For instance this is my Query: $args = array( 'post_type' => array( 'providers' ), 'post_status' ...
1
vote
0answers
157 views

Blog post per page setting conflicting with custom WP_Query?

I am creating a theme, and have run into a problem with how a custom WP_Query seems to interact with the Blog pages show at most settings found under Settings -> Reading in the WordPress backend. I ...
0
votes
1answer
32 views

Get posts for each user

For a project with students I use WordPress with Timber (TWIG) + ACF Fot this project I created 3 custom post types : dissertation, subject-imposed and subject-free Each student can create only ONE ...
0
votes
0answers
46 views

Limit custom post type to the authors only on front-end!

I'm trying to limit the custom-post-types to their authors excluding administers on the homepage. This is how the code looks like on the homepage.php <?php $args = array( '...
0
votes
1answer
101 views

Post Filtering by GET URL parameters

I am trying to add a simple filter for posts in my wordpress site by setting parameters in the URL, however it is simply not filtering the posts which is driving me crazy. All the tutorials or forums ...
0
votes
0answers
21 views

How do I stop the same post showing multiple times in a archive?

For some reason the archives for my custom taxonomy is showing each post 3 times and I can't seem to figure out why. Here is the page: https://portfolioadviserlink.com/topics/esg/ $...
0
votes
0answers
9 views

Question: How can I retrieve the post details liked by the current_user using the post_id from the “Different” post_type?

I am soo new to Wordpress development, so I am so lost in this. I have a custom post type "Like" that automatically adds the post_id of the page/post the user liked, and the "Like" post type contains ...
0
votes
0answers
23 views

How to add Adsense code in between posts?

I am using the Genesis Framework for my coupon website. I am using the function genesis_custom_loop to create WordPress posts loop. Reference for genesis_custom_loop: https://genesis.community/wiki/...
1
vote
1answer
104 views

new WP_Query(), have_posts() return false in user_register hook

The $notifications->have_posts() return false, though I'm sure there are few posts of this custom type, in the database. add_action('user_register','jq_after_user_register_hook', 10, 1); function ...
0
votes
1answer
57 views

WP Query - Show custom posts only if user contain some user meta

I am trying to make a list of custom post type which going to show all posts but only if author contains custom user meta named "activeacc". So.. I have thic code... $args = array( 'post_type' =&...
0
votes
1answer
381 views

Group posts in a category based on tags in custom taxonomy

I had my built-in posts set up with categories and tags. I created a template that would display posts of the category that matched the page slug. then it would group them by the Tags. for example, ...
0
votes
1answer
15 views

Get posts that match defined arrays of tags

I've been scratching my head a lot and couldn't find a reasonable solution that would not require multiple queries. In my case, the posts have multiple tags, but they can be divided into to "sets" ...
0
votes
1answer
24 views

Query for current post

I want to show current post.I will use this query in single template for custom post type.When click the custom post type, only the post will shown. How can I write this query? In wordpress ...
0
votes
1answer
102 views

Multisite how to display merged posts from two sites and sort by latest date?

I'm using multisite and pulling blog posts from 2 sites. The below query displays the posts but does not merge the posts together, it just lists all of site 1 posts followed by site 2 posts and ...
1
vote
1answer
113 views

Order a query result by a numeric meta key even if it does not exist, but put the posts with meta key first

I want to order a WP Query result by a numeric meta value in PHP. To achieve this, I am doing as follows: $query->set( 'meta_query', array( 'relation' => 'OR', array( 'key' =&...

1
2 3 4 5
24