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
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
13 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
22 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
64 views
+50

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
11 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
21 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
34 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
11 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
27 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
29 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
122 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
18 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
18 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
16 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
17 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
28 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
23 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
87 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
18 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
40 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
46 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
90 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
26 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
47 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
20 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
104 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
70 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/...
0
votes
0answers
73 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
136 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
25 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
215 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
63 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
18 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 ...
0
votes
0answers
50 views

Custom Static Page to Display Blog Posts in Excerpt Non-Singular Form (is_singular not working?)

I have been trying to change my code from my index.php to a custom page template instead as this is better practice I have been told. The original code for the index.php does not work anymore so I ...
0
votes
0answers
16 views

Filter post by category with pagination

Hi i want to display all categories on frontend as a checkbox and filter the blog post based on checkbox selected with pagination , any help please
1
vote
0answers
25 views

Get link which associated with a specific category and tag

We have 500+ post, 60+ tags, 3 categories. We want to give link on header part which have specific one category and one tag. For example: We have multiple post like: Blanket, Blender, Mixer, Wardrobe ...
0
votes
0answers
20 views

post_per_page and multiple categories

I need some tips for the code, I need to get 5 posts per every category, but this is show 5 post at all.. <div id="projects-carousel" class="owl-carousel"> <?php $query = new WP_Query( array(...
0
votes
1answer
177 views

Should I reset $wp_query?

I am not totally new on WordPress but the query thing is a bit confusing to me. I searched the web and read a lot of articles, but I couldn't find what I needed. Maybe it could help a lot of people ...
0
votes
1answer
46 views

Performance considerations - postmeta table versus new table for custom posts with foreign keys?

I am modifying a plugin that uses various custom posts types. The types are courses lessons topics At course, lesson, or topic level there can also be quizzes and assignments. ALso the ...

1
2 3 4 5
24