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
751 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
67 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 ...
0
votes
1answer
75 views

get_posts seems to be skipping the last Post

I have custom post type (Events) with 6 events. $posts = get_posts( array('post_type' => 'events') ); echo '<!-- '; print_r($posts); echo ' -->'; This code shows the 5 with the most recent ...
-1
votes
1answer
703 views

How to show only text from post in WordPress

How do I retrieve just the text of a post in WordPress not including any pictures?
0
votes
1answer
768 views

Getting the list of the latests posts and custom type posts in the homepage

When I need to get a single post type list I usually use get_posts, how can I retrieve multiple custom posts types to populate the site homepage? To be more precise, I would like to get the latest ...
0
votes
1answer
409 views

Exclude post format from get_posts

The title basically says it all. I know I can use the following to get posts from the aside post format: $args = array( 'post_type'=> 'post', 'post_status' => 'publish', 'order' ...
4
votes
1answer
535 views

How-to exclude terms from the main query the most performant way?

This Q is a follow up to this answer on the Q: "How to exclude a specific term for the search?". 4 ways to filter out posts that have a specific term Type | Pro | ...
0
votes
1answer
106 views

Why would get_posts be ignoring posts with 2-digit ids?

I'm using this code to list child pages of the current page and similar code to get child pages of all ancestors to use in a sidebar contextual hierarchical nav menu: $pageset = ...
0
votes
1answer
393 views

Load the last post of a category

I would like to load the last post when I go to the selected category. For example if I go to http://site.com/category it loads http://site.com/category/35/this-is-the-last-post Does exist some ...
0
votes
1answer
2k views

how to call the category of the post

I jus want to create a gallery which shows either all or certain number of posts in that category under each post and i found a working code <?php $displayposts = new WP_Query(); //get posts ...
0
votes
1answer
308 views

Random Image Script Working but Want to Avoid Duplicates

I'm using the following to display random images: <?php $new_query = new WP_Query('&showposts=24'); ?> <?php while ($new_query->have_posts()) : $new_query->the_post(); ...
0
votes
1answer
434 views

paginate posts on admin page

I've created a plugin that calls a list of posts and grabs external API data. I am using get_posts to grab the list (because I need to feed the array of links into the API query) For whatever reason, ...
0
votes
1answer
107 views

Can I include get_posts in this array?

I am using the custom meta box script from deluxeblogtips.com and I wondered if I could include get_posts within this array so that it displays all posts within a set post type ("Locations" for ...
0
votes
1answer
809 views

get_posts not working as expected

I'm trying to get posts from 3 different categories and list them on the front page: // Carousel articles $args = array( 'numberposts' => 3, 'orderby' => 'date', 'category' => ...
-2
votes
1answer
93 views

append $_GET parameters to post

I try to find a plugin that can "auto insert" to post edit/add page a parameters by fill $get paramerts: for example:post.php?title=a&tags=ss,dds,aa Ideas?
1
vote
1answer
216 views

get_posts that haven't been assigned a specific custom field

I'm trying to use get_posts() to pull articles that have not been assigned a specific custom field. For example (not working): $articles = get_posts(array( 'post_parent' => 0, 'post_type' ...
0
votes
1answer
630 views

Magazine style frontpage with multiple categories/loops and no duplicate posts

I am migrating a static magazine site to wordpress. I would like to have a frontpage displaying multiple categories with a few posts in each, e.g "politics", "environment", "health" and "technology". ...
1
vote
1answer
1k views

How to query with get_posts() for posts with any tag

I need to do a simple post query that will get any post that has at least one tag. This is my current code that gets the posts with tag ID 27 or 36, but I need to modify it to get all posts with at ...
0
votes
1answer
130 views

Load posts from external source if not found in database

I want to modify WordPress so that it requests content from a function if content is not found in the database. I want to edit the section of the code which requests and returns the post content ...
0
votes
2answers
127 views

get post id using custom filed value

I'm having custom field "prime" with values yes or no. I want to get the post id's with selected value "Yes".How can i get that. Thanks in advance
0
votes
1answer
143 views

Getting the Posts' permalinks from XLMRPC

I'm new to WP and I must fetch pages/posts from a blog in another subdomain. I'm using ZF to do this. I've recently found out the getPages doesn't get me what I want (posts; duh!). I didn't see any ...
0
votes
1answer
87 views

Querying a query

Let's say I have a query stored in a array. I want to parse this array, find the first posts inside this array that match a certain value from a certain key, and so extract the whole post. Is there ...
0
votes
1answer
143 views

Get posts in archive page

I am using this code to show posts in columns. How can I set this part ('cat=3&numberposts=5&offset=0') as so archive page should automatically get posts from clicked catagory? <div ...
1
vote
2answers
836 views

Only retrieve posts where post_excerpt has been filled out

I'm trying to use get_posts to only return posts that have an excerpt. Done lots of searching and have been trying to use "posts_where" filter on the query but my SQL is lacking. This is what I'm ...
1
vote
1answer
1k views

how to exclude “featured” posts from the main loop?

In a category.php template, I built a function that lists "featured" posts before the main loop. The featured posts are selected using a custom field and get_posts(): function ...
2
votes
2answers
544 views

get selected post using $_GET

im trying to get a post info when I click a button on the post and make it echo out the the same info it has in the else function, I tried adding in a query but in return it makes it echo back all the ...
5
votes
4answers
9k views

setup_postdata() does not seem to be working?

I am not sure why but I have used get_posts() to query for some data. Then I used setup_postdata() ... I think its used so that I can use functions like the_permalink() etc with the new post data? ...
0
votes
1answer
4k views

Can I use numberposts=-1 and offset together when using get_posts()?

I'm currently using get_posts() for a little part of a theme I'm working on. However, I've run into one little hiccup. If I want to show all posts for a category, I set the 'numberposts' argument to ...
0
votes
1answer
940 views

get all categories' latest post in one query

My WP blog has 12 categories, 80 subcategories. I need to fetch the latest post from each of those 12 categories. I know how to do it in 12 queries using 12 get_posts() but is there a way to get ...
1
vote
1answer
2k views

Exclude Current Post from Recent Posts Loop

what would be the best way to exclude the current post I am viewing from this recent posts query. Thank You! <?php global $post; if (in_category('top-lists')) { ...
0
votes
1answer
4k views

exclude category from get_posts?

getting posts by cat with get_posts but need to exclude another cat called london or id 10. is this possible? best, Dc. // array(7,-10) $laargsM = array('category' => 7, ...
0
votes
1answer
1k views

Get the ID of the latest post

Been all over looking for the best way to do this. I want to get the ID of the latest post of a certain post_type. How can I do this in the cheapest way possible (by cheapest I mean using the least ...
0
votes
1answer
1k views

Paging result of get_posts in function

I have created a function to use as a shortcode to allow me to display a specific post type on my page. The function works well, but I would like to the results to be paged, and the navigation only to ...
1
vote
2answers
1k views

functions.php conditional tag only for custom post type

I'm using gpp slideshow, which overwrites wordpress's default gallery display. I only want to use it on my custom post type, "listings" - how would I reference it to only replace wordpress's default ...
1
vote
2answers
304 views

making random query button using $_GET

Im trying to make my post random when i lick on my button using $_GET but it just keeps refreshing my page instead of refreshing with the random post. <a href="<?php echo $my_query; ...
0
votes
1answer
3k views

Newbie Question: How to create a “latest news” page showing a list of posts from blog category

I am using the Modest theme from elegant themes at http://lilsaintz.co.nz Under the slider on the homepage, there are three content areas that are generated from pages. I would like to make one of ...
0
votes
1answer
769 views

List one post only from each subcategory using get_posts?

Custom Post Type = 'projects' with a Hierarchical Taxonomy = 'projects_category' projects - big-corporates -- company one ---- first project 1 ---- second project 1 ---- third project 1 -- company ...
1
vote
1answer
556 views

get post attachment using ajax

I'm developing a plugin and I'm trying to get the url's from a post's attachments with ajax. If the user is on a single.php page. After some seconds, I'm sending an Ajax request, getting all the ...
0
votes
1answer
650 views

post__in not taking my list of IDs

I have a Custom Field on a page named banner_id_list. I have a Custom Post Type called top_banner. I add a few banners, note the IDs and then go back to the page and add a comma delimited list of IDs ...
0
votes
2answers
393 views

How to query the latest 5 posts and sort them by title?

I'm looking to draw a menu listing of the latest "n" number posts, where the number "n" will be a user defined setting stored as an option. n = 5; //Pull the latest 5 posts from the database. The ...
0
votes
2answers
2k views

How Can i Get 5 Recent Post Title With Corresponding Link?

I Want to Add My Latest 5 Post Title with Corresponding Link in My Header Position.What was the Actual Php code?Am Newbie ....
1
vote
2answers
1k views

Trying to only display 1 category using get_posts

I'm trying to only display posts from a certain category in a widget. I've tried it in a few different ways but it is still showing posts from all categories. Here's my code at the moment: $posts = ...
1
vote
1answer
780 views

Automatically republish old posts

been seaching on google for a plugin for this and can't seem to find anything realiable. The only plugin I found is called "old post promoter". Any ideeas? Can this be done with googl old fashion ...
5
votes
1answer
537 views

How to organize and cache additional data associated with terms?

I'm updating a plugin of mine and am have a hard time figuring out the "best way" to build in a specific bit of functionality. The plugin allows users to associate images from their media library to ...
1
vote
1answer
997 views

Adding Pagination on a Custom Author Page

i have created a custom author's page that list the title of their posts. but the problem is i can't get the pagination to work if it's beyond the set post per page value. i have used get_posts() to ...
0
votes
1answer
141 views

Not able to get random post

I want to display a single random post out of the 5 latest posts in the category 'news'. The approach I'm using is this: // Custom function to retrieve catgory ID by category name. $cat = ...
0
votes
1answer
361 views

How to query custom post types with multiple keys?

I recently upgraded WordPress from 3.0.x to 3.1.2. I had set it up to use custom post types before the upgrade. I need make a list of events that are occurring that started in the past until they ...
0
votes
1answer
5k views

How to get The Loop working with $wpdb->get_results()

I am doing a rather complicated custom query on a blog's front page, and trying to show the results using The Loop as shown here: Displaying posts using a custom SELECT query The query filters posts ...
1
vote
2answers
5k views

Does meta_query work within get_posts array?

I can't seem to get this to work — I'm trying to show posts that have the meta 'featured_image' value set to anything. From what I can tell, it's set up correctly, but I'm in a little over my head. ...
0
votes
2answers
116 views

WordPress echoing content in seemingly random place

I have been building a series of theme pages. On one page a users messages (post_type=messages) come in in a tab on the page. The content is displayed in place as is the title etc.... The content is ...