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
2answers
120 views

Function to grab specific image IDs from media library.

I want to grab images 161 thru 166 without having to calling my entire media library array and having to splice those up. In time, the more I have in there the more it's going to slow my site down. ...
0
votes
1answer
205 views

Show all posts using the template page and the loop?

I am trying to make a template page that would display all posts from all categories, in short - every post added to my website. I was googling around and found out that it can be done by using The ...
0
votes
0answers
81 views

nesting a loop with sticky posts?

I am trying to retrieve two types of posts composing a total of 5 posts on the first page of a site the first post is styled differently to the following 4 posts (to maintain a sense of clarity let's ...
0
votes
2answers
62 views

While loop articles - if statement order

I want to show a list of articles, but I want to show in the 1st place my second article and after it the last. Eg: Article 1 Article 2 Article 3 Article 4 to be: Article 2 Article 1 Article 3 ...
0
votes
2answers
226 views

Use WP_Query or query_posts() or get_posts() for optimizing a site?

I have read other answers, but I don't understand which is more fast (the best and simple for slow server running)? I have a website with over 1 000 000 hits /day and a slow server with limitations ...
0
votes
1answer
80 views

get_posts always returning the same number of posts = 5

I don't understand why the code below is always displaying the same number of returned post = 5. When I change the $variable value to another post id of a post with an author with another author_id, I ...
0
votes
2answers
142 views

Modified home page query does not yield expected results

Yesterday i asked how it would be best to load all existing pages and their content on front page - to create single page layout. (Single page theme) From the info on that page i created my own ...
0
votes
0answers
125 views

Multiple Drop Down

I have been trying to make a multi-level(relational/dependable) drop down menu. What i really want to do is, give the user to search for a mobile company(lets say Samsung) and then show the Phones ...
0
votes
2answers
164 views

how could I get the pagination as I want to when query posts using get_posts function

I am using WP3.5, and I have a post_list.php which will show all the posts order by post date DESC. Everything is ok except pagination. I have 15 posts, for test purpose, I want to every page show 2 ...
0
votes
1answer
221 views

Trying to check and see if a post has a featured image outside of the main loop

I've got a situation where I need to find out if the currently loaded post has a featured image, if it does, I want it to display a different logo than if it doesn't have a featured image associated ...
0
votes
1answer
67 views

“paged” in WP_Query returns 0 posts

If i don't supply a paged value (get the first page), it works. But when i try to get the next page by doing paged => 2 it doesn't find anything even though there are plenty of posts to get. ...
0
votes
1answer
137 views

Getting URL Variables with a Rewritten Page (Login Page)

As part of a larger project, I am attempting all login activity to occur at the following address: www.url.com/login So, a link that should lead to a form that would allow a user to reset their ...
0
votes
1answer
85 views

Get posts from 2 different categories

I have a custom post (it's called "ait-dir-items") and 2 categories there. On category archive page, I need to get posts which belong to 2 categories. get posts from 2 categories Codition. ...
0
votes
0answers
78 views

get_posts() and 'posts_per_page' arg

$args = array( 'posts_per_page'=> -1, 'post_type' => 'listing', 'meta_query' => array( array( 'key' => 'ListingRid', 'value' ...
0
votes
2answers
174 views

get posts from 2 categories. (2 posts)

I have a custom post (it's called "items") and 2 categories there. 1. on category page, I need to get posts which belong to 2 categories. get posts from category1="Food" and category2="featured" How ...
0
votes
1answer
80 views

get_the_title outputs title until spacing; it does not get full length of title

If I have a post with a spacing in it (like: Hello World), than get_the_title shows me only "Hello" as a link and not the whole permalink. I already tried using a substring to get it done, but it did ...
0
votes
1answer
111 views

How to get all post titles starting with numbers and symbols?

I want to get all posts which are starting with a number (0-9) or symbols, in a list. I managed to get it work for letters, but this one is harder for me. Can someone help me out please? I tried ...
1
vote
1answer
91 views

get_posts - find out if querystring was crap and fallback is used

If we pass a String to functions like get_posts, and that string is not a meaningful querystring (for Example get_posts(' ')), the function returns the results of the default query (the last five ...
0
votes
2answers
326 views

Don't submit post if post title exists

I am using the User Submitted Posts plugin which I love. The only problem with this plugin is that it does not check for duplicate post titles and outputs a post with the same title, even if it ...
0
votes
3answers
261 views

shortcode for recent custom type post

I'm not a coder so I may have done some "coding" crimes, apologies. I've bought a theme who has shortcodes for last posts but not for last "custom post type". So I tried to create last "custom post ...
0
votes
1answer
78 views

List latest posts with least comments in WP-Admin

I want to encourage my authors to provide feedback to new posts that have not received enough exposure. To do this, I want to add a box to WP-Admin that lists the top 3 latest posts (from the past two ...
0
votes
1answer
51 views

Turn get_posts as string into an array for use in theme admin options

I am trying to add a drop down list of all posts into a theme admin section...without forklifting the theme code. I need to pass the post title and id into the 'options'=>array() like so: ...
-2
votes
1answer
230 views

Related Posts Without Plugin And get_posts( $args ) ?

Is there a simple way to get related posts without having to use a plugin? I am preferably looking for something really simple like a couple lines at most I currently use this to get random posts, ...
0
votes
3answers
68 views

Wordpress ultra slow if I click on posts?

I have 5000 posts on my website, which I have uploaded from a CSV file. This all went well and the website is fast on the back-end and frankly on any other page. There is one exception: if I click on ...
0
votes
1answer
81 views

Internal linking to posts permalink fail because of spaces and stripe at postname

I have written a function which outputs a tag in a textarea in which people can link internally to other posts on the website. This works like a charm except with using a postname permalink ...
0
votes
1answer
644 views

Advanced Custom Fields: Post Object - Not returning data [closed]

I have a custom post type called "Training" with an archive page (archive-training.php). I have another custom post type called "Courses". I am using Advanced Custom Fields: Post Object to link ...
0
votes
1answer
95 views

get_posts() doesn't consider user permissions

I want to show a list of links to posts for the logged in user on my wp. So I started to do so: $posts_array = get_posts( array( 'post_type' => 'download', 'post_status' => 'publish' ) ); ...
0
votes
1answer
102 views

Bulk Attach Or Insert Media To Post Without Opening Post Editor

How to create a custom panel inside wp admin dashboard where we can insert media to specified posts in bulk? Here is the illustration: As shown on the image above, it list all available media on ...
0
votes
1answer
43 views

Display Posts with template on a Page

OK, I'm sure some WP pros here will think this is a dumb question, and I'll probably get some flak, but I have actually read plenty of documentation, and I just don't think I'm even going in the right ...
5
votes
1answer
941 views

What does setup_postdata ($post ) do?

The codex defines it as 'Set up global post data. Helps to format custom query results for using Template tags.' I don't really understand this. Here is a code example : global $post; $args = ...
0
votes
1answer
3k views

Count posts returned by get_posts in external PHP script

I'm using WP from an external PHP script by including the wp-load.php file. All functions and everything works as expected so far, except one thing: I can't get the $wp_query->found_posts to work ...
0
votes
1answer
268 views

AJAX pagination call to get_posts with an offset and a meta_value_num sort returns same post on adjacent pages

I have a simple AJAX pagination that seemed to work just fine, calling one Wordpress page (not ideal, I know) with a pagenum and a sort order arguments and it returned 4 custom posts per call. The ...
0
votes
1answer
26 views

Number of displayed posts

I have tried many things to solve this problem. So I have a plugin which displays projects assigned to users in a widget. It displays projects as posts. The problem is that it only displays 5 ...
0
votes
1answer
412 views

Retrieve Image Attachments Getting Post Thumbnail Image First

I have written a funtion to get post image attachments, is there any way of ordering these images such that the first is always the post_thumbnail? Code below Thanks John function ...
0
votes
0answers
43 views

How to count RSS posts from a custom URL?

In my RSS feed, for example in a custom conditional URL: domain/?m=20130407&feed=rss2&cat=3 I'm getting all my required tags, after editing wp-includes' file feed-rss2.php With pagination ...
0
votes
0answers
90 views

get_pages not returning any results or error when get_posts works

I have a code sample that works with get_posts but I now need do with get_pages so I can get grandchildren in the results set: $attachments = get_posts( array( 'post_type' => 'attachment' ...
0
votes
1answer
1k views

tax_query in get_posts() not working?

I'm trying to print out all the posts within every taxonomy for a custom post type called product (jigoshop products). So i get all of the taxonomies using $cats = get_terms('product_cat');, then i ...
0
votes
0answers
248 views

Showing sticky posts with get_posts()

I'm using this to retrieve posts on my index page: <?php $posts = get_posts( "category=13&numberposts=2" ); ?> <?php if( $posts ) : ?> <?php foreach( $posts as $post ) : ...
0
votes
1answer
239 views

Show the title of the latest post by author

I have the following function which I use to show the author name,author avatar and the author biography in a div. I need to show the title of the latest post by the author along with this. Can anyone ...
1
vote
1answer
339 views

Custom Loop, Match Category with Page: How to display post featured image?

I found this answer. It saved my day, but could you tell me how to display featured image of the post with the following code? When I'm using <?php echo $cpost->post_thumbnail('thumbnail', ...
0
votes
1answer
62 views

Show posts in a list separated by day

I want to display posts on index page within a links-list, with only the titles, till now i did the job, but now i want to have space between titles and be separated by day. Please check wimp.com ...
1
vote
1answer
172 views

Limit popular posts by days

I am using this get_posts array to retrieve top 15 popular posts by comments. The problem is that it shows those all those highly commented posts from the day posts were added into blog. So, the list ...
1
vote
0answers
317 views

get_posts() with pagination problem

<ul class="list"> <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'category' => '8', 'orderby' => 'post_date', ...
1
vote
0answers
44 views

Query Problem in getting top viewed posts

I wanted to display top viewed posts by month, I add this code snip, to form a query and get required 15 posts, but it displays 3-4 posts.Here is my query: global $post; $args = array( ...
0
votes
1answer
188 views

Query specific number of posts for each post type in specific order

This is related to this other question, I tried with get_posts, pre_get_posts, WP_Query and basically every option I could find for 2 days now, no solution yet. The full problem in hand: I have 2 ...
0
votes
1answer
1k views

Pagination with get_posts seems to work but links not showing

I've a custom page template where I want to query 2 posts from a post type and 1 post from another post type. I have it set up like this: $paged = get_query_var('paged') ? get_query_var('paged') : 1; ...
0
votes
1answer
54 views

Specify strict 'order by' in WordPress query

I have a custom post type called Employees where an employee's name is the post_title of each post. I am trying to figure out how I would sort the post_title column by last name. So for instance, if ...
0
votes
1answer
177 views

get_posts post title permalink not working for last item in array

I have a custom field attatched to a post that contains the following array of post titles... a:6:{i:0;s:21:"Strawberry Cheesecake";i:1;s:15:"Flapjack";i:2;s:14:"Chocolate Muffin";i:3;s:27:"Apple ...
0
votes
1answer
165 views

Get_Posts, only if in both categories

get_posts('numberposts=5&category=93+85')get_posts('numberposts=5&category=9385') Is there a way to have get_posts grab only posts that are in BOTH categories, as above?
1
vote
2answers
977 views

Using query_posts inside single.php loop

Inside of my loop in single.php, I used a custom query using get_posts to return posts belonging to a certain category. <?php global $post; ...