Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

-1
votes
2answers
41 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
0answers
16 views

Show categories not in gallery post format

I want to show all blog categories that aren't of type gallery. My code almost works but if I have 2 posts in the same category the category is shown twice ie: If I create a category called 'news' ...
0
votes
0answers
20 views

can i add admin menu for set query category id?

I am thinking of something.that i want to add a wordpress admin menu for set category id. i mean i designed news section that lists post from specific category. like this: Sports News Post from ...
0
votes
2answers
23 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
27 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
54 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
18 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
81 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
41 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
24 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
68 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
26 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
12 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
16 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
41 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
70 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
26 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
63 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
17 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
0answers
43 views

Query multiple Post Types that have the same Taxonomies with different Terms

I have a method that works. However, it's not very optimal and limits WP_Query's functionality (recently with pagination). I saw a similar question/issue, but the answer provided is the current ...
0
votes
2answers
21 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
34 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
120 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
0answers
51 views

Query with multiple CPT but custom field for only one on them

I need the query with merge of two CPT posts (for example cpt1 & cpt2). The problem is when is need to add the 'variable' only for one CPT, that is the a custom field and relevant value (for ...
0
votes
0answers
12 views

How to create page in admin panel. that show pending post list

I want to create new page under posts menu, that just show pending posts list. I create page under post, but i dont know what should write in function add_action('admin_menu', 'my_theme_menu'); ...
0
votes
1answer
19 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
0answers
20 views

Loop Query - How do I use WP_Query with the standard Wordpress querystrings?

I am wondering on the best way to approach a particular (common) scenario. I have a standard wordpress website, with various pages. I have one page currently designated to be the "blog" - this is ...
0
votes
2answers
66 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
37 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
30 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
21 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
22 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
43 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
8 views

specific post always at 3rd position in a category page

I have already searched but found nothing useful. im Develop a Wordpresstheme. I would like to have a post always located at 3rd position in a category page. Another at the 6th place. At first I ...
0
votes
0answers
34 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; ...
0
votes
0answers
47 views

Restricting Fields in wp_get_recent_posts

Looking at the function, there is no way to successfully restrict the fields in wp_get_recent_posts, is the only solution to write a WP_Query from scratch for a plugin? Im requesting a lot of ...
1
vote
1answer
299 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
80 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
606 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
90 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
36 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
31 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
vote
1answer
45 views

How to query custom post types posts filtered by multiple custom taxonomies through a form selection

I'm trying to create a sort of selection menu, in order to select custom posts by different custom taxonomies. I did the selection part, but I can't get to output my post and I can't understand where ...
0
votes
1answer
427 views

Quickest way to get last or oldest post date - WP Query

I know how to get the last or oldest post data using following code $posts = get_posts(array( 'post_type' => 'post', 'order_by' => 'publish_date', 'order' => 'ASC' )); And then I will ...
1
vote
1answer
102 views

Reset Popular post query?

I am using the following code to display most read articles. I think it takes the lifetime of the articles as it displays very old articles first. How can I reset it - weekly? in my function.php ...
2
votes
1answer
57 views

How to get previous 10 days post from a specific date - WP Query

I want to know how to get previous 10 days post from a specific date, as I know that it can be done from current date as below $args = array( 'post_type' => 'post', 'date_query' => ...
1
vote
1answer
26 views

how to make members list directory through wordpress post custom meta key.

I have created a website in which I am providing complete information about the organization. For this, I am using a Wordpress post. In which I am putting information of only one organization in a ...
1
vote
1answer
63 views

How to display certain category in the loop from WordPress default post type?

I want to display a certain category from WordPress post type, but it is not showing... Here is my quote. it displays all posts instead of "wedding venue" category post. <?php $args = array( ...
1
vote
1answer
110 views

How can I pick a single post from the latest 3?

I'm looking to display a single featured post from my latest 3 posts at random. I've managed to get it up and running picking any post at random just fine, but I want to filter it down to only the ...
0
votes
0answers
28 views

Wordpress For Loop Prints Unwanted Extra Paragraph Element

I have the following code to list my authors in my sidebar except for the admin account. It works very well in function. However, it prints an extra paragraph element that includes two ancor tags with ...