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
2k views

get excerpt without images

Is there any way to not get the images with get_the_excerpt()? I am using a my_recent_post() function to pull posts onto the home page and I don't need to have it pull the images within the posts, ...
1
vote
1answer
1k views

Getting a custom post type image using 'get_post_custom'

I am trying to echo the image src of an image I have uploaded for my custom post type outside of the while loop. I have used the following: $custom_fields = get_post_custom($_GET['id']); I can ...
0
votes
1answer
120 views

Select objects from get_posts()

How can I select the first/last object from the list returned by get_posts()? How can I select the preceding/following object relative to an arbitrary object in the object list returned by get_posts? ...
2
votes
3answers
2k views

Post count per (day/month/year) since blog began

I'm looking to echo the number of posts per month since the blog began, and for months where there was no posts echo '0'. This is the output I want: January 1, February 3, March 8, April 3, ... ...
0
votes
1answer
514 views

How to reset post data properly

I have this piece of code that I am calling within the loop to get image metadata ( title/caption and description ). It works fine but it only works for the first post in the loop. So I assume it ...
1
vote
1answer
317 views

Show recent posts from one category on a non-WP site

I'm trying to move back to WP for our blog, after struggling with a clunky CMS for a few years, but we'll be sticking with that CMS for the rest of the site. Is there a plugin (or code) that I can use ...
1
vote
1answer
304 views

Location-Based Pages displaying results near customer

I'm creating a website where the customer will enter their postal code and the pages (with a distance selected of 5, 10, 20 miles) will display on either a Google map or Bing map. The page results ...
0
votes
2answers
671 views

Divide the list into two columns (get_posts)

The function below lists posts based on custom field. The result is involved in a list <li></li>. What I would like to do is count how many list items there are, then divide it into two ...
0
votes
1answer
188 views

not empty categories don't show in menu [closed]

I'm trying to resolve a problem i have showing category posts. I have added a category to my main menu, eventhough it has posts - in the basic theme it doesn't show, in my theme - it shows as a link ...
2
votes
0answers
433 views

How to reload a select box of posts dynamically?

I'm using custom meta boxes for a project. I have created a custom taxonomy (select box) and I have another select box populated with Posts. I need to only load the posts based on the selection of the ...
1
vote
1answer
3k views

get_posts with meta_compare='LIKE' not working

I am using the following code: $tolettpe = "Sale";//default if($_REQUEST['tolettype']) $tolettpe = $_REQUEST['tolettype']; else if($_REQUEST['srch_type']) $tolettpe = $_REQUEST['srch_type']; $args = ...
1
vote
4answers
7k views

get_post random and order by not working

I have this code that returns list of post title as links, but when I add the 'orderby' and 'order' parameters - it returns results but 'orderby, order, rand' do not work, can anyone tell me what I'm ...
0
votes
1answer
99 views

get_query stops working after post filter

I'm currently trying to set up some filters for a custom post type within my admin. The custom post type is 'players' and I'm filtering them by another custom post type 'teams'. To create my ...
0
votes
1answer
273 views

Display a random customposttype2 excerpt in single-custompostype1.php that shares same taxonomy

OK - Looked everywhere for this one. Details: Custom Post Type #1 = 'product' > registered taxonomy 'productranges' Custom Post Type #2 = 'testimonial' > registered taxonomy 'testimonials' Both ...
0
votes
2answers
235 views

Sorting posts by specific order

I have a custom post type and I want to be able to control the order that the posts are displayed by defining the order in an array, and then checking the posts meta_value against the array to see ...
0
votes
2answers
648 views

get_posts not working on homepage?

I have a simple custom shortcode plugin where you give it a tag and it'll display the titles of all the posts with that tag. e.g. In my post if I type "[listposts tag=oct-2011]" it will output the ...
1
vote
1answer
292 views

Get posts inside Get terms problem

i have a get_terms which loads correctly. inside of it i have used get_posts. then using get posts i am trying to get each post tags (and count <= not currently inside this script) <?php ...
0
votes
1answer
389 views

What is the p parameter in a get_posts() parameter array?

I've seen code that looks like this: get_posts(array('p' => $thumbnail_id, 'post_type' => 'attachment')); What is the definition of the p parameter and is it documented anywhere? I can't find ...
1
vote
2answers
131 views

Why is querying posts messing up my pages?

I am working on a theme at the moment and I have set up a post template. This post template is linked to some custom post types. When I query_posts for my post type on the actual post template ...
0
votes
2answers
906 views

Conflict between wp_list_pages and get_posts - list pages not displaying

This has only been a problem since I updated to Wordpress 3.1 I have a page that displays a list of custom post types. The page is the child of a parent page. There is a sidebar that lists sibling ...
1
vote
1answer
510 views

How can I paginate a list of related posts?

My client's home page displays a paginated list of posts with thumbnails. Each list item, when clicked, navigates to a single post or page, and then uses a separate query to generate the same list of ...
0
votes
2answers
1k views

Add filter to get_posts

So I am attempting to filter out certain posts in the get_posts call. Essentially, I want to be able to specify a certain block of posts, and only get the posts that correspond with the block. Right ...
0
votes
2answers
1k views

get_posts displaying wrong permalink for “continue reading” link

I lifted the "continue reading" link functions from the Twenty Eleven theme and for the most part, it is working (works in RSS feeds). I created a shortcode to display the latest post on the front ...
3
votes
1answer
119 views

How to add paging to query

In the script below, I'm calling out from archive.php to functions.php to retrieve a list of posts that have been flagged in a category reserved for my "blog" posts. I'm listing these posts in summary ...
0
votes
1answer
69 views

Use get_posts() with 'post' and 'page' queries at the same time?

I'm trying to grab all posts which are 'posts' and not in category '3' and '5' and which aren't 'pages'. Is this possible to do using one single get_posts()? Because I'm querying both actual posts and ...
0
votes
3answers
210 views

Delist entries in the_loop

I am trying to add a delisting feature to my WordPress network. Posts which are delisted would not appear in post lists, but would still be visible if accessed directly. I've written a plugin that ...
0
votes
1answer
2k views

the-events-calendar, pagination with tribe_get_events()

i'm using the events calendar plugin and at some place i use the tribe_get_events() function to show the upcoming events. Point is, i need to create a pagination for those results. The ...
0
votes
2answers
256 views

loop inside a loop : search for posts in the same category

Could someone tell me how i could make this work? i have a loop, and i would like to create another loop to find the other posts from the same category : but this does not work : <?php while ( ...
2
votes
2answers
230 views

How to get 4 Posts after the 5 most recent ones

Well, I think the question might be a bit confusing. But well, I want to get the recent 4 posts, ignoring the first five recent posts. So in short the sixth, seventh, eighth and ninth - most recent ...
0
votes
1answer
52 views

How to pull a list of posts in a category while exluding posts in subcategories of the category

I'm using a get_posts() call to pull a list of posts in a specific category. However, the recordset also includes posts in subcategories of the target category. How can I exclude subcategories from ...
0
votes
1answer
359 views

Hide gravity forms

I have gravity forms set up on my site and I am wanting to hide/show a form based on whether or not the user has posted an entry into the form/database. If they have made an entry, then I want to hide ...
0
votes
1answer
2k views

Query only Posts from Both of Two Category?

I have 3 categories, 1.OnGoing projects(cat id='5') 2.Completed Projects(cat id='6') 3.Upcoming Projects(cat id='7') and also i have another 2 categories:(Not a Sub Category) chennai (cat ...
2
votes
2answers
633 views

How to generate a list of posts published on current day?

I want to create a page labeled "Today's News" which displays a simple bulleted list of all posts published on the current day and grab the current date based on the server's date/time. Is this ...
0
votes
1answer
3k views

How to query custom post type by term?

This seems trivial but I can't get it to work. Here's my code: $args = array( 'numberposts' => -1, 'eventcategory' => 'nice-events', ...
0
votes
2answers
393 views

List 'n' number of posts from a Tag, each with a different class or ID

I want to list 'n' number of posts (ordered by latest first) -- post's title linked to the post's permalink -- from a tag on my WordPress blog. I also want to assign each link its own class or ID. I ...
0
votes
3answers
82 views

Is it possible to retrieve a post and its metadata at the same time?

I usually use two steps to retreive a list of posts and the associated metadata: call get_posts(or a custom WP_Query), and then loop through each post returned and retrieve each posts metadata one by ...
1
vote
1answer
106 views

Sort posts by most recently modified

Is there a way to list posts in the order in which they were modified? For example; A user posts 5 posts (#1 being the oldest and #5 being the newest), by default they would be listed with #5 being ...
0
votes
1answer
2k views

Adding paging to get_posts()

I'm trying to add paging to the query below. However, I can't seem to get the paging to work. It shows previous/next links, however, they always show the same 2 posts. There are 8 posts in this query. ...
2
votes
2answers
1k views

How to get posts by content?

I found the following codes to get post details. However, it is not possible to get the posts by content. Does any one has any ideas? get_posts() //// get post //// $args = array( 'numberposts' ...
0
votes
1answer
162 views

Using post title as term in query, only working with single word titles

I am using get_the_title to set up the taxonomy term for my query, which has worked fine in testing up until I had a title with more than one word, title of "catalogs" works, title of "new catalogs" ...
4
votes
1answer
450 views

Sanitation needed for WP_Query or get_posts calls?

Just wanted to get a straight answer on this: when submitting query_vars to a call to get_posts or WP_Query, is sanitation needed or does WordPress already take care of that?
1
vote
1answer
2k views

Get_Posts and multiple categories

I have created a custom query in hopes of showing the top posts from some child categories. It appears here: http://www.sitesofconscience.org/activities/whats-new The query has a big flaw: some posts ...
0
votes
1answer
559 views

get_posts() method and paging is not working

Trying to use paging in one of my Wordpress site but seems it is not working.for paging i am using SEO Pager Plugin. here is my code $params = get_query_var('args'); $ppp = ...
1
vote
1answer
1k views

How do I combine these 2 queries

I want to combine the 2 following queries so that ongoing promotions (query 1) shows before the rest of the promotions (query 2) but all together no more than 5 results show. Thanks. Query #1 Ongoing ...
0
votes
1answer
1k views

Calling setup_postdata() causes “Call to undefined function get_userdata()” error?

The exact error is: Call to undefined function get_userdata() in /wp-includes/query.php on line 3567 I am using get_posts() in my plugin, which in turn uses setup_postdata() wherein ...
0
votes
1answer
232 views

Both a page loop and posts loop on the same page

I'm trying to get first the content of a single page (the one that is queried), and then in a small section below i want to display the title of my bloggposts as a "Latest News" section. The problem ...
0
votes
1answer
482 views

Remove posts from query for events whose start date has passed

The query below works as expected, showing cpt event ordered by meta_value, what I haven't figured out yet is how to remove posts for past events or events which have started. The start date for ...
0
votes
1answer
159 views

PHP Syntax Error on get_posts

I have the following coding: <?php global $post; $args = array( 'numberposts' => 8); $myposts = get_posts( $args ); foreach( $myposts as $post ) : ...
0
votes
1answer
863 views

Single random post in homepage

I want to display single random post in it's entirety in the homepage.I've tried many methods, but the main issue was that it won't display the content, only heading, or display content, but only an ...
0
votes
1answer
68 views

How do I query posts and have their related taxonomies returned in the results?

I have created a custom post type that contains television channel data. Each channel has its own post. I have also created a custom taxonomy of channel groups. What I want to do is query all the data ...