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
14 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
9 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
23 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
15 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 = ...
-1
votes
0answers
14 views

How can I do metabox filtering?

I have a post type. I have a private domain within this post type. My special area is a date. I want to filter by post type and end date. How can I do that? Thank you in advance for your help.
0
votes
0answers
13 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
15 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
24 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
15 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
79 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
15 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
22 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
42 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
16 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
14 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
41 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
32 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
18 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
16 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
124 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
24 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
23 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
21 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
17 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
8 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
19 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
42 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
26 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
124 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
20 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
43 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
49 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' =&...
4
votes
1answer
110 views

How to exclude latest x posts from a paginated query?

I have a WordPress loop, that is part of an AJAX call. Every time a button is clicked, this function is called, runs the below loop and outputs the next 6 posts. There are already five posts shown by ...
1
vote
1answer
27 views

Two loops, one AJAX loop, exclude posts in first loop from second loop, loops are in different files

I have two loops that display posts: the 'default' loop (in home.php), which displays five posts. At the bottom of the page I have a button, that invokes an AJAX call, which calls a second loop and ...
0
votes
0answers
10 views

Delete repeated posts in the result of mysql query

I created a custom post type with a taxonomy and a postmeta (I used ACF for the postmeta). And I try to get the articles of my custom post, but I have a problem: My first post repeats itself several ...
1
vote
0answers
54 views

Gutenberg get core data - search

I am trying to query data in gutenberg like search in REST API. Following this documentation: https://developer.wordpress.org/block-editor/data/data-core/ I came up with this select: wp.data.select(...
0
votes
0answers
21 views

Get Posts from Specific Custom Post Type Seperately on Taxonomy Page (tag.php)

I am trying to Get List of all custom post type (Album) for the current tag (post_tag) page (tag.php). Lemme explain further: E.g I used Drake has a post_tag taxonomy while posting Albums (album ...
0
votes
0answers
21 views

How to get post from all custom post_type multisite to the main site with pagination ordered by date?

Currently this is my WordPress Multisite: Main site -Sub Site -Sub Site -Sub Site -Sub Site and this is the example code for getting all post from multisite : foreach( $blog_ids as $id ) { ...
1
vote
1answer
148 views

add active class based on permalink and url

i am facing a issue, on my wordpress site in left side i loaded post list with title and excerpt, and when you click on that content will get load on right side of page and its working fine but i ...
0
votes
1answer
85 views

Get latest posts from multisite

I've created a multisite on a local VM and installed my theme. Now I'm trying to get the latest posts from all the sites in order to display them ordered by last updated on homepage. From what I've ...
0
votes
1answer
20 views

Modify default Related Posts Code to Custom Post Type

I'd like to modify this basic related posts code to my custom post type "Videos". Since I'm new to this stuff, can someone help me understand what I need to modify in this code so that it pull related ...
-1
votes
1answer
30 views

Pagination in category.php not functioning

Original Url: https://www.something.com/category/ftm-atf/ When I add pagination in, the following url is generated which results in a 404: Paginated Url: https://www.something.com/category/ftm-atf/...
1
vote
0answers
82 views

WP_Query adds “(wp_posts.ID = '0')” so no results are returned

I am doing a very simple WP_Query: $query = new WP_Query([ 'pagename' => 'some-post-slug', 'suppress_filters' => true // used by WPML to search in ANY language ]); However, the ...
0
votes
1answer
149 views

Custom query to retrieve oldest post and retrieve others with date interval

I am looking to implement a custom post query that includes the following parameters: WordPress custom loop to select the oldest post from a custom post type and display it on the page. There are ...
0
votes
1answer
26 views

On what hook can I get the queried object's final state?

My goal here is to create a mini-plugin that allows me to create social share links, as such, I am very, very interested in getting the most up-to-date version of a queried object's link/title. I've ...
1
vote
2answers
274 views

Bypass “supress_filters” in WP Query

Apparently, for some illogical reason, the developers decided that the only way to fetch posts in all languages, is to add supress_filters=true to the WP_Query (instead of having like say, a ...
0
votes
1answer
78 views

Use WP_query to match post types based on custom field values

i'm trying to query posts from the post type Product that match with the current post in the loop from the post type Item, based on the custom fields product-ean and item-ean. For example: i have a ...
0
votes
1answer
19 views

Top rated posts Average rating issue

I am trying to show top rated posts, cpt with AVG rating value.I created the custom widget for this. Defaults wp posts data and AVG value is showing correct but a CPT like Movie post not showing ...

1
2 3 4 5
24