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

1
vote
1answer
23 views

How to get the post content from a category on my homepage

I'm trying to get posts with a specific category to show in a box on my home page. But ive only been able to get one post on my homepage. How can I make this work in the code below? With getting the ...
0
votes
0answers
8 views

Getting post content within wp_nav_walker

I have a custom walker set up designed to add content into the nav menu. The problem being that it is not pulling the content. The post object returned by the get_post/get_page has an empty ...
0
votes
2answers
27 views

Query posts by a type and another type only if post is in specific category

I have a featured post type and a reviews post type. I would like to include reviews of a certain category (I use categories from the posts type) as well. How could query args be crafted? A crude ...
-1
votes
1answer
15 views

Can't get Category link inside get_posts

I created a simple function to display the latest posts. Inside the function there is a conditional to display the post category. I found that to display the category name, using $category = ...
-1
votes
0answers
32 views

ACF - post object not returning anything

i have 2 post types 1 stores which has title and customfield storeurl. i have another posttype called books with title . i assigned the posttype stores as taxonomy to books using field type as "post ...
0
votes
1answer
14 views

How to get post content from an array of ids?

How do I get post content if I have an array of id's. Basically, I have a function that get post content if you provide an ID. but it doesn't work if I have an array of id's. My function is: function ...
-1
votes
1answer
16 views

how to ask if in two categorys inside if

I'm new two wordpress so sorry in advance if this question might be very basic. Depending on which category a post is, I do some script things and I ask inside the loop in this way: <?php if ...
1
vote
0answers
26 views

Posts are not showing up on particular category

On my website, post are not showing up when I navigate to http://www.domain.com/category/category-name/ but on wordpress dashboard, I am able to see the actual number of post under that category. ...
0
votes
0answers
49 views

Why WP_Query in functions.php is not working when get_posts works?

I have following code in my functions.php. When I try to add new post_type (e.g. post,lawyers) it fills excerpt,slug (this affects in permalink structure), other metaboxes from first post of lawyers ...
0
votes
0answers
12 views

Custom Shortcode that includes filtering by tag

Within a custom shortcode, how do I filter the posts that come back from get_posts() such that only posts with Tag = "xyz" are returned? Here is what I have in my shortcode currently: $args = array( ...
-1
votes
1answer
48 views

posts_per_page - Repeats only first posts 'post__in' array

This question correlates with a previous question I was able to solve here: http://wordpress.stackexchange.com/a/137929/28389 I am using an array for 'post__in', and I am able to run this no problem. ...
0
votes
2answers
41 views

get_posts() returns all posts rather than the ones specified with 'post_author' =>

I want to retrieve an array with the posts of a certain user for a custom post type category. However, get_posts($arg) returns ALL posts of this custom post type, although I specified the post_author ...
0
votes
2answers
61 views

How to use Wordpress Conditional Tags in get_posts foreach loop

I have a page which has a jquery tab function to output the list of pages that are the children of this page (Bio, Archives, Contact). However I am trying to make a conditional in the foreach loop ...
0
votes
1answer
33 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
11 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
43 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
30 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
52 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
43 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
55 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
20 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
58 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
26 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
26 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
39 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
77 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
36 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
22 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
33 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
40 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
71 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
53 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
45 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
52 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
30 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
45 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
46 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
77 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
31 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
38 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
1answer
174 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
3answers
269 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
63 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
51 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
85 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
163 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
64 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
87 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
25 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
102 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 ...