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
1answer
144 views

Get total posts found, but while using limit for pagination? get_posts

I have a ton of posts that I need to get the IDs of based on a custom taxonomy search. As it's used for pagination, I also need to get the total posts without a limit, but I'm not sure how. I use the ...
0
votes
0answers
20 views

return custom taxonomy terms in post object

How would I go about returning the custom taxonomies in the post object with WP Query or with get_posts for that matter. yes, I know I can loop over my query and use get_terms or a number of other ...
0
votes
1answer
123 views

get_posts ignoring 'category' and displaying all posts

I'm going a bit crazy on this one. I'm trying to display a list of posts in a category on an Admin page in a plugin I am writing. The following code works fine on my dev server (OS X/Apache): $args = ...
0
votes
0answers
148 views

get_posts multiple criterias

Hi I'm trying to get only posts from a certain category, but also all other posts that have a certain field value. for example: all posts in the "News" category. but also all posts marked as featured ...
0
votes
3answers
87 views

How to show more than 5 posts?

I am running code that shows child categories, and all posts in the child categories. But if there are more than 5 posts in a category, only the 5 newest are shown. How can I show all, or at least ...
0
votes
0answers
93 views

How do I get post attachments in menu_order in Wordpress?

I'm struggling to get menu_order to work for images attached to a post. I am trying to pull all of the images attached to a specific post in the order specified via the drag-and-drop interface in the ...
0
votes
0answers
134 views

Post per page not working

I have 2 parent categories are app and game. Beside them has child categories. My code get 6 post from 2 parent categories with orderby post date and order DESC, but post per page not working. Please ...
0
votes
1answer
37 views

Show all videos by tag name

I need to get all videos by tag name, im using code like that $tax_terms = get_terms('media_category', 'orderby=count&order=DESC&hide_empty=0'); foreach ( $tax_terms as $tax_term ) { ...
0
votes
1answer
158 views

Sort posts by title, sort array by largest number [duplicate]

I am using the post to display attorney verdicts and case details. The post title is the verdict amount entered as a string. (no $ "," or ".") I am formatting the title using PHP number format: EX: ...
0
votes
2answers
40 views

get_posts() in secondary sidebar messes up content in primary sidebar

I use get_posts() to generate a menu of posts having the current page as the parent. This causes the post_id to be set to the first such post, instead of the original page's post_id. I.e. I want ...
0
votes
1answer
82 views

setup_postdata doesn`t seem ot be working

I'm having issues with setup_postdata(). From my understanding, if I want to use functions such as the_permalink() or the_title(), I must use setup_postdata(). Right now, the_permalink() or ...
0
votes
1answer
87 views

Get posts by list of post IDs ordered by those IDs?

I am going to make a "favourite" posts box, but the article id's are stored in another DB so I only get an array of IDs (which are relevant to the WP DB). I think it could be done with get_posts() or ...
1
vote
1answer
177 views

How do I restart my loop with get_next_post()?

I'm looking for a succinct method of making get_next_post() double back to the beginning once it hits the last post. Currently, it stops once it hits the final post. Here are a few lines of code from ...
0
votes
0answers
86 views

How can I give Wordpress child custom post type the same title and slug as its parent?

I have two custom post types, one is the child of the other (the parent is more of a modal post). I want the child post to inherit the same title and slug as its parent. I've tried to use the ...
0
votes
0answers
36 views

more tag not recognized but content is truncating

Specifying truncating posts of category 'news' on homepage. Trim works but not recognizing the <!--more--> code in posts... from homepage. code in homepage ...
0
votes
2answers
74 views

How to properly use Categories with Custom Post Types

I'm really struggling with this... I created a few Custom Post Types, let's say... Books CD's Maps Now I also have a whole bunch of existing categories and some of these would apply to more than ...
0
votes
2answers
50 views

Strange get_the_* behavior with php 5.4

Let me try to explain what happened to me : I have a shortcode plugin which display child pages of the current page (a mod of http://wpist.me/wp/child-pages-shortcode/, very useful). In the display ...
0
votes
1answer
141 views

How can i catch (with get_posts) attachment file (pdf, images) from a post when i have only inserted it from media library and it isn't upload for it?

I'm sorry for my english. I discover a strange behavior in WP get_posts when i try to detect from a post an attachment (in my case a pdf file) inserted from the library. This is my code: ...
0
votes
1answer
95 views

Retrieve latest post by multiple categories with ID

I have the categories listed below in my product post type. Category Name: Test 1 ID: 82 Category Name: Test 2 ID: 83 Category Name: Test 3 ID: 84 Category Name: Test 4 ID: 85 Now I want to ...
1
vote
1answer
54 views

Why does my widget break other widgets?

So this widget i created is killing all other widgets registered in the same sidebar. Meaning, nothing renders after this widget does. No other widget markup makes it to the DOM. After hours of hair ...
0
votes
0answers
71 views

Combining / Merging two queries?

So I am working on an isotope filtered portfolio page that pulls any attachment tagged with the term "digital-interactive". Each attachment is also linked to a custom post_type called "work". On one ...
0
votes
0answers
37 views

get-posts pull 2 levels of sub pages

The template structure is: a Product index (parent page) b Product category (sub parent page) c Product single (page) They're all Pages, not Posts. 1 On index page, to pull out the page title from ...
0
votes
1answer
65 views

Show recent posts in single-post page

I'm trying to show recent custom posts in single-events.php I can make it work by using get_posts what I don't know how to do is exclude the post that is active so if I'm on 'Event 1' just now using ...
0
votes
0answers
82 views

404 Error is showing when open page posts

I just downloaded the video theme from templatic, when i am displaying videos from the thumbnail, it shows 404 error Link to the page It is not showing the video, how to avoid this problem and show ...
0
votes
3answers
138 views

Get post offset/posts page offset in single post page (outside the loop)

I would like to know how I could get the offset of a custom post or its page, outside the get_posts loop. I developed an external web application which connects to the wordpress blog with JSON API ...
0
votes
0answers
38 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
63 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 ...
1
vote
1answer
360 views

get_posts() not working in functions.php

If I use the following function in any theme template, it works as expected. However when trying to use it within an AJAX function in my functions.php, it returns empty. $args = array ( ...
0
votes
2answers
686 views

Get id of category from drop down menu

Im trying to get the category ID from wp_dropdown_categories();and then pass the ID into a loop to have it output posts titles from that particular category. I currently have this: <form ...
0
votes
1answer
91 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
62 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
2answers
353 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
181 views

How to show more post at a given category?

I need to show more post at the category state (with tag_ID=21), for example, I set the number of post show at homepage is 6, but I want 10 post when archive state, is there any way to add a filter in ...
0
votes
1answer
118 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
140 views

External link not showing on post but showing on comment

Why is this? For example, if I input this in a post: <a href="http://i2.wearecdn.net/images/2012/11/47/article/vans/so6099412/vans-authentic-schuhe-bright-green-black-1755-zoom-0.jpg">This ...
0
votes
1answer
32 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
120 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
44 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 ...
0
votes
1answer
136 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
45 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
87 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 ...
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
170 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
143 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
42 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.); ...
0
votes
1answer
199 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 ...
3
votes
1answer
248 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
2answers
251 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
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
93 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 ...