get_posts() is a function for creating multiple loops. It retrieves a list of latest posts or posts matching criteria.

learn more… | top users | synonyms

0
votes
0answers
36 views

loop with the last commenter on each post on specific category

Hi i have the following code that lists the posts from specific category and the date, post author, the last comment author, last comment date and the avatar for comment author for each post on the ...
0
votes
1answer
57 views

List all pages including archive

I'm creating a custom options page on my site. One of the options is controlling a box on the homepage and i'm trying to set the link for the item to any page on the site via a select menu. as of now ...
0
votes
0answers
108 views

WordPress multisite post clone

I have 2 theme on my wordpress multi-site, its a property site. One theme is general and another is map theme. Now my platform users are placing property from general (site1) and I want to show them ...
0
votes
1answer
82 views

get_posts and wp_autop (remove filter)

I just transformed my query_posts function in a get_posts function. Here is my old function: <?php // The Query query_posts( 'cat=170&showposts=4' ); remove_filter('the_excerpt', 'wpautop'); ...
0
votes
1answer
59 views

get_posts output always same post

I'm trying to output the last (chronologically) 4 posts having the tag (slug) "pp". <ul> <?php $args = array( 'posts_per_page' => 4, 'taxonomy' => 'tag', 'field' => 'slug', 'terms' ...
0
votes
0answers
578 views

How do I paginate a get_posts() request inside another page loop (Paginating childpages)

The heading says a lot, so I'll repeat it here "How do I paginate a get_posts() request inside another page loop?" I'm using a page to display child-pages and I need to paginate them. Edit: Should I ...
0
votes
2answers
247 views

How to restore deleted pages/posts?

I recently deleted some pages in my wordpress site. Now I want to re-store them. How can I do this? Any suggestions will be appreciated. Thanks in advance
0
votes
1answer
98 views

Is get_posts() more efficient than The Loop?

In category.php, I want to get list of posts in that category. I found two ways: using get_posts($args) and The Loop. get_posts() way $args = array ( "category" => ID ); $posts = ...
0
votes
0answers
35 views

Advanced meta query help

I want to get posts according to the following logic: "If post status = publish or pending then get all records which have a meta value of less than todays date. If the post is in trash, get it ...
0
votes
1answer
113 views

custom post type upcoming post and past post

I want to retrieve inside my archive-CPT.php most recent upcoming post ( post with status of future) and past post (oldest published post). This is how my archive-CPT.php is looking like: <?php ...
0
votes
1answer
29 views

How do I get only a certain number of images from a post (minus the featured image)?

I have the following code (see below) that lists all attached images from a post. I'm trying to alter this code to only list the first five images, and also to exclude the featured image from the ...
0
votes
1answer
42 views

Exclude categories from homepage not longer working

I was using query for excluding categories from my homepage without problems until this week. I'd like to know the reason of the change and a better way to get this. I was trying also diverse ...
3
votes
1answer
205 views

Get all authors with at least one post of 'custom post type'

How can i achive that? I found count_user_posts and get_users, but how would I merge them into the desired result? Do I really have to use a WP DB Query?
0
votes
1answer
119 views

Retrieve posts in custom post type and specific taxonomies

I'm struggling with what seems like should be so simple looking at the codex. I have a custom post type, let's call it 'portfolio'. A custom taxonomy for that, let's call it 'clients'. I can use ...
0
votes
1answer
41 views

How to query posts to include specific pages of one post type, and all pages of another post type?

I'm having trouble figuring out how to query all posts from the post type "events", as well as including four specific pages in the loop. If I use the "include" parameter, it only returns the ...
0
votes
0answers
76 views

WordPress Page Template to Display Page Title, Custom Field, and Date

I'm currently attempting to create a page template that will display all posts by the current logged in user, a particular custom field from those posts (i.e., Item Status), and the dates those posts ...
1
vote
3answers
2k views

get_posts only children from certain parents

I have parent posts (custom post type hierarch=true) with ID 1, 2, 3, 4. The parent posts with ID 2 and 4 have child pages. I need to retrieve only posts 2 and 4 and all of their child pages. ...
0
votes
1answer
154 views

Test if a post exists by category and date

I would like to check outside of the loop, if a certain post exists in a specific category and from a specific date. The function get_posts() -- if I get it right -- allows me to check, if there are ...
1
vote
1answer
131 views

Wordpress count child posts of each parent custom post type and use in json array for google maps jquery plugin

So i have been looking for a couple of days now and cant find a solution to this anywhere. It is a fairly bespoke request from a client... I am using a jQuery google maps plugin to add markers for ...
0
votes
1answer
41 views

Yet another get_posts() in explicitly defined order problem

I am creating a 'loop' that needs to display pages (not posts) in a defined order of ids. What I did till now is: <?php $ids = array(434, 814, 3660, 3235, 99, 1002, etc.); ...
72
votes
3answers
39k views

When to use WP_query(), query_posts() and pre_get_posts

I read @nacin's You don't know Query yesterday and was sent down a bit of a querying rabbit hole. Before yesterday, I was (wrongly) using query_posts() for all my querying needs. Now I'm a little bit ...
0
votes
2answers
212 views

pagenavi shows alot of pages calculated from all posts in the site with query_posts

I need to excute posts from 2 seprated keywords using s=keyword with get_posts, but only searching in titles. I found this answer. I created a custom template to use it in single page. Then I used a ...
0
votes
1answer
175 views

Can't pull posts of a Custom Post Type based on the custom taxonomy of the CPT

My question is about retrieving custom post types via get_posts, when custom post types also have a custom taxonomy. I can use get_posts to retrieve all posts of a custom post type, but when I attempt ...
0
votes
1answer
33 views

Search for pages with permalink

I'm searching for posts this way $args = array( 'name' => $permalink, 'post_type' => 'page', 'post_status' => 'publish', 'posts_per_page' => 1 ); $posts = get_posts( $args ); ...
0
votes
0answers
86 views

Wordpress sort custom field values in alphabetical order

I am using WordPress Custom Content Type Manager to build a Literary Agency website. The page I'm stuck on is the Authors page which displays thumbnails of all the books related to the author. The ...
0
votes
0answers
33 views

can't reset get_posts

I have three loops in my theme that I want to use to get menu items for a lunch, dinner and wine list menu. The first loop worked fine but when I added the second one, the system broke. I did some ...
0
votes
1answer
34 views

Why only one post (and no pagination) on this variation of the loop?

This is my WP loop: // fetch latest news stories $paged = (get_query_var('page')) ? get_query_var('page') : 1; $posts = get_posts(array( 'numberposts' => 3, 'paged' => $paged, )); // ...
0
votes
1answer
182 views

Problem: ( kriesi ) pagination doesn't work in homepage [duplicate]

When I set this template as homepage, pagination doesn't work. I see the buttons, but when I click the button for page 2, nothing happens, doesn't go on page 2, it still remain in page 1. What is ...
0
votes
1answer
102 views

Retreive tags from attached post for media on page

I am working on a custom template file that pulls all images in my Media Library with a specific tag. I was able to get this working with some help from the community, it also shows the title of the ...
-1
votes
1answer
145 views

get posts based on category and post meta

I am coding a Live Show box for a radio website to show who is on air and who is up next. I've been using the get_post function to retrieve posts based on the category (in this case the day of the ...
1
vote
2answers
128 views

Wordpress not opening posts with only numbers if permalink is post_name

Someone knows why this happens? For instance, I have a post called 1987, but it does not open it when I click on the link. When I use a different permalink structure, it opens it. Why is this and how ...
0
votes
1answer
237 views

Select post from dropdown and add query args not working

The behavior of the below should be that the user makes a selection on the dropdown box and the page refreshes with a query arg of editevent=1 and also passes a value of the post ID with the selection ...
1
vote
1answer
1k views

get_the_content(“more…”) returns full text

I'm creating shortcode [latest_post] and want to show post date, title and short content. (content has "more" separator). Here is code: function shortcode_latest_post() { global $post, $more; ...
1
vote
0answers
351 views

Get Recent Posts by Date in Multisite

Everything in explanation is about CDTuts I've created a WordPress Network and I want is to get the recent posts from all of the selected subdomain blogs. I need to get the latest All organized by ...
0
votes
0answers
45 views

Trying to combine a variable together

So I am not 100% sure if the is feasible so hopefully some one can point me in the appropriate direction. I am using the Advanced Custom Fields plugin and on my custom page template I am using the ...
4
votes
2answers
483 views

How to get current post ID in quick edit callback

This question is related to another previously asked question, which is a follow up on an answer. Task As I want to extend QuickEdit to be something really awesome (and more than just quick edit), I ...
0
votes
1answer
367 views

Get title of post image is attached to

So I found this post: Find the post an attachment is attached to and implemented Chip's suggestion but having a weird outcome. I am trying to pull the title of the post that the specific image is ...
2
votes
2answers
1k views

How to get all children and grandchildren of a hierarchical custom post type?

I need to get all sub-posts of a specific (root) parent id. get_posts( array( 'numberposts' => -1, 'post_status' => 'publish', 'post_type' => 'microsite', 'post_parent' => ...
0
votes
2answers
97 views

Transient Loop Not working as expected

So I created a transient object that used get_posts() to get a series of posts based on some argument. Well the transient was stored - it was created - YAY - now I tried to write this loop: public ...
0
votes
1answer
245 views

get comments and get posts in loop

I need to get posts done by specific users and get also comments done to these posts, so far I can get the posts and comments but can't get how to do it in loop properly, because now I get the same ...
-3
votes
1answer
190 views

Get all posts without tags

I'm working with a tag plugin. Is there a WordPress way to get_posts or query all posts that have no tags?
0
votes
1answer
56 views

How to show only 1 post from a specific category on the front-page

On my front-page i have a 3 col block section below the fold. The final and third column is an excerpt of the most recent post from my art category blog, hopefully this is clear up until here in terms ...
0
votes
0answers
188 views

get posts with hierarchy and all post meta

I created a custom post type to act as a Family Tree. There are currently 40+ post-meta fields that collect all of the important information. Wordpress's built in "parent" function is used to assign ...
0
votes
2answers
242 views

Add Filter not working with get_posts

While tweaking the "Bryans Childpage Thumbnail Generator" plugin, I am applying filter (with pagination) to the get_posts for WP Pages (post_type=page), but its not filtering at all. Here is the code: ...
0
votes
0answers
101 views

show/hide attachments

Is there a way to show/hide attachments in my case images on a post. What I want is to mark an image as "hidden" and then only show it to the admin and hide hidden images from a normal user I know ...
0
votes
1answer
56 views

Query for draft or scheduled post

What should be the query for checking if there is any draft or scheduled post, I'm not able to make which arguments to take. Thanks
0
votes
3answers
397 views

Get only used meta_values

this is how I'm getting the meta values: $apart_locations = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = 'postal_location' ORDER BY meta_value ASC" ); This is how ...
0
votes
2answers
465 views

use get_posts to get custom field data, but in one array

I've run a get_posts query in WordPress and need to pull a pair of custom fields and get all of them into one array. The get_posts query provides an array of posts, but when I use foreach to access ...
0
votes
1answer
429 views

What's the difference between “get_posts” and “wp_get_recent_posts” when used with “setup_postdata”?

This might be a completely "I'm still new to WP" type question, but I ran into some interesting output when using get_posts() and wp_get_recent_posts() in a custom function I wrote with ...
0
votes
1answer
233 views

Custom Post Type children and grand-children in one list

So, here is the story: i made a product catalogue with 3 custom post types: - Product - Filegroup (Child of Product) - File (Child of Filegroup) When on product page it should show a ...