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
51 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
21 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
191 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
48 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
33 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
94 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
21 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
2answers
68 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
549 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
62 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
1answer
56 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 around ...
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
191 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
140 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
137 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
30 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
596 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
37 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... ...
0
votes
1answer
217 views

trying to change from query_post to WP_Query

I am running a theme which is using query_post now I am trying to change it to WP_Query. However I am always getting a blank empty page with just the header. This is my query: query_posts(array( '...
0
votes
0answers
26 views

Problem with my loops

I am French. Sorry if i make mistakes. I have two problems. The first, I have a page that shows all paying activities sort by date. The 'posts_per_page' does not work When I put 10, it shows 8 ...
0
votes
1answer
1k views

wp_query with ajax

I am trying to filter posts by year using WP_QUERY with AJAX And the current builder i am using is DIVI(for front end). Result Everything loads fine and i am facing one final roadblock that is when ...
0
votes
2answers
277 views

How to query most recent post for each author?

Can anyone provide a sample MySQL or WP_Query code snippet that returns the most recent post for each author on a single WordPress site? For example, if the site has 10 authors but 500 posts, then the ...
1
vote
1answer
33 views

Duplicated posts on category page

So, I have archive.php file with this part of code <div class="column is-full is-three-quarters p-small"> <?php while ( have_posts() ) : the_post(); get_template_part(...
0
votes
1answer
36 views

Sorting query_posts() with a complex orderby filter

I'm trying to order my posts with a complex orderby scenario which uses the CASE and WHEN syntax. To achieve that, I've created a filter : add_filter( 'posts_orderby', 'order_properties_by_reference',...
0
votes
2answers
84 views

one post per term taxonomy

I need some help, again. I use this query: $tax = get_the_terms($id, 'coupon_category'); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ...
0
votes
3answers
94 views

query_posts problem - need help

I have a taxonomy called coupon_category. In a query_post I am trying to call all posts from related custom taxonomy with the same coupon_category. If I use: <?php // show ...
0
votes
1answer
488 views

Query post with meta_query where date is not in future

In my args I would like to exclude posts where the datum_event is not in the future. Currently it only displays posts with datum_event values that are in the past, but because older posts don't have ...
0
votes
1answer
1k views

How to display Related Posts based on number of taxonomy terms matched

I have a custom post-type 'News' which has multiple custom taxonomies 'news-category', 'news-tags'. Each post contains between 4-8 'news-tags' and 1 'news-category'. For my current post, I'd like to ...
1
vote
0answers
46 views

ACF Query meta_values don't work with 'offset'

I am currently building a featured posts section and I'm using ACF to set which posts will be featured. As they're appear in another section, I want them to start in this query on the third post. ...
0
votes
2answers
26 views

How to give classname to post if post has no content?

I want to give a post a classname on the homepage (index) if the post on the single page has no content. So when the post itself exists but there is no content, I want to give a classname to that ...
2
votes
0answers
48 views

List custom post type by custom tax term as page title

I have a page called "Developments" and I want to list all the Project posts by the custom tax Project Type using the page title as the term. This doesn't work: <?php $title_slug = ...
0
votes
1answer
420 views

How to display liked posts of current user in wordpress?

Im using an ajax like dislike post system on my wordpress theme. When the user likes the post there are some post metas to update or to add like the following: if( $post_like == "like" ){ ...
0
votes
1answer
255 views

I need query_posts() to order results first by a meta value and then by post ID

I've read all the WordPress docs that seem relevant, and I've read lots of posts here and on other sites to find an answer to this, but I still can't find a way to do this. I have a custom post type. ...
0
votes
2answers
273 views

Get all posts which was posted on X Days WordPress

I want to get all post which was posted on X Days, I don't want 7 days old post or 1 Month old posts, Because it will return all posts which will be older 7 days or one month. Like Today is 15 SEP, I ...
0
votes
0answers
165 views

How can I use query_posts to loop through posts and construct my own content?

I am using query_posts to combine two posts categories on a page (by inserting this simple php script on the page using a plugin). This script gives me all the posts I want, however one of the ...
0
votes
0answers
67 views

My archives page won't sort posts by month

I'm trying to make my own theme and I've created an archive template that works fairly well. The template shows all posts, but the problem is that all posts will show if I go to /2018/11/ (posts were ...
0
votes
1answer
30 views

How to display particular categorie's post which associated to specific user?

How to display particular categorie's post which associated to specific user? http://tugsemegtei.mn/category/fish/ Above link displays all the posts under fish category, but how can I display only ...
0
votes
2answers
43 views

minimize wp_query call to database

I have a very basic question which can be done easily with raw sql query where instead of * we can name the columns of database we want output like select id,name,date from tableA where id>'...
2
votes
2answers
54 views

Ordering terms before displaying posts

My question is close to other questions, but I dont' have enough reputation to comment. I'm working for a restaurant and I 'd like, for my menu page, to organise my posts "meal" under terms "...
0
votes
0answers
58 views

Pagination doesn't work in query post in tag template

In tag template I use the following query post: global $query_string; // required $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; ...
1
vote
1answer
1k views

Rest Api How to get results of child categories with one api call

Example: If I have a parent category 1 with child categories 2,3,4 etc instead of a call like this: /wp/v2/posts?categories=1,2,3,4 i want a call like this (imaging code) /wp/v2/posts?categories=...
0
votes
1answer
215 views

How to get post ID in a Page?

I'm trying to list all of my posts in a page(with post's content). Everything is showing correctly but the audio player which uses post id to get the URL of an attachment in the post is not showing. I'...
2
votes
1answer
2k views

Display custom post types with custom date field value (before today) & order by custom date field

I'm trying to display custom post types with custom date field value being before today. It works OK for showing posts before today, but the order is only based on post date. I want to have the result ...
2
votes
2answers
441 views

Query all posts and not repeat the same tag

I need a query to show all posts in the site but not repeat the ones with same tag, I mean only show one post with the same tag. My current query is <?php $paged = (get_query_var('...
0
votes
2answers
108 views

Separate First Post Loop

I'm trying to use the <?php rewind_posts(); ?> feature to use two loops on my homepage template. Does anyone know how to stop the first loop after the latest post? Here is my Code: <?php ...
0
votes
0answers
54 views

Specifying image size used in template the_content

I have a template that is used to display all posts. It uses query_posts with a set of $args that I specify. The template uses the_content to output the content of each post (text and images) I want ...

1
2
3 4 5
24