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
9 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
13 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
16 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
57 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
14 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
15 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
22 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
38 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
59 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
21 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 ...
0
votes
0answers
21 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
18 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
15 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
31 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
47 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
14 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
29 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
51 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
115 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
22 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
102 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
28 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
14 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
47 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
14 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
23 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
16 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
104 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
45 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 ...
0
votes
0answers
25 views

how to add 4 post in one carousel slide

I want to display 8 posts in twoeach carousel slides, that mean 4 post in each slide. i'm using a loop to display post but the problem is, it is showing one post in one slide and hence displaying 8 ...
0
votes
1answer
68 views

query posts custom field calculation value

I have a front-end form whereby users create a post and input 3 numerical custom field value` as part of their post. These 3 custom fields are then calculated and the result is displayed in the post....
0
votes
1answer
19 views

Ordering of posts, 2020 Year showing as next event when should be last

We have some event posted into wordpress which are ordered by date. All works well except when we enter an event for 2020 it comes at the top of the list rather than the bottom. The date is save in ...
0
votes
0answers
17 views

What would be the best approach for querying posts with multiple templates from a custom post type

I'm a bit stuck with querying all the posts from a custom content type where posts have multiple templates and display all the posts on a page. As shown from the image below, each block inside the ...
0
votes
2answers
42 views

Order Posts in Custom Order

I am trying to create a custom way to order my new custom post type. Here is what I am envisioning: There would be a custom way to order posts in an entirely unique order for display (Number, ...
0
votes
1answer
207 views

meta_query check for meta value in key which holds an array of values

In every post of my custom post type called "announcements" I save the users' ID inside an array which resides in a meta_key called "post_is_read" whenever a user reads an announcement. Just to ...
0
votes
0answers
39 views

How to show post views shortcode data for each post on Posts List Page?

Example: [shortcode id=""]. I just want to how to dynamically fetch each post ID on Posts Lists page over archive page or normal posts page inside the shortcode placed in excerpt. Currently I'm using ...
0
votes
0answers
107 views

Woocommerce - Do not show out of stock variation on filter

When I filter by size, it will display all products that have that size, even if the specific size from the product is out of stock. I would like it to not display products that the filtered size ...
0
votes
0answers
25 views

How to add results to wp-query with pagination?

I'm trying to add results with pagination to the main query results with custom arguments. But the problem is that I'm getting the second loop result in every pagination page. The goal is to add them ...
0
votes
1answer
46 views

Counting Search results, and displaying the offset per page

I'm trying to achieve the following search result counts while using pagination; Showing 1-9 of 368 Items - (Page One) Showing 9-18 of 368 Items - (Page Two) but I'm getting myself turned ...
0
votes
1answer
11 views

Order by meta date with a thousanth of a second defaults to post order

I have a custom post type query: $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $args = array( 'paged' => $paged, 'post_type' => 'my_custom_post_type', '...
0
votes
0answers
23 views

Custom query for custom post type not getting correct post ID

I have written a custom query here: <?php $the_query = new WP_Query( array('post_type' => 'video', 'posts_per_page' => 10, 'post_status' => 'publish') ); ?> <?php if ( $the_query-&...
0
votes
0answers
24 views

Remove post name of custom WP_Query when using in pagination?

Is this possible? I am trying to get pagination working on my pages and single pages. It seems like it's working, as it recognizes how many pages there are and shows the URL. The problem: the URL is ...
0
votes
0answers
131 views

Slow page loads due to WordPress Core Query

I have a page with many posts and every single page load is noticably slow. Hence, I have checked with Query Monitor the culprit(s) for the slow loading time and found that one query in particular is ...
-1
votes
2answers
80 views

prevent display duplicate titles on main page

I am using a automatic rss post reader on my website and there is a problem with this plugin that sometimes publish duplicate posts.I can't do anything to this plugin but at least it is better if I ...
0
votes
2answers
81 views

Filter Custom Taxonomy Posts

I have a custom taxonomy page, it also has a slider up top. The problem is the slider displays random posts from all taxonomies rather than the current taxonomy. Is there a way to filter the images in ...
0
votes
1answer
29 views

Query Post interferes with Pagination

Here is my situation, if you look at the following page: http://staging.cancerwellness.com/mind-body/cancerversary/, you will see that the pagination is not working. After researching the problem, I ...
1
vote
1answer
380 views

Get posts by category with pure SQL query

I have a meeting post type, whose titles automatically get set to a date of the form m/d/Y. I have the below query which gets all unique years from the post titles by selecting distinct values after ...
2
votes
1answer
29 views

How to make the list of post and load on same page with sub-pages [closed]

http://jeffkoons.com/artwork/early-works How can I make a page on WP like this drupal site.? Thanks
0
votes
1answer
1k views

Posts Query | Query to only show sub categories

EDIT: Up to date code, only thing left to fix is the subcategory query. I'm struggling to get my portfolio page's filter to work. I have quite a good knowledge of WordPress and cannot seem to... ...

1
2 3 4 5
24