get_posts() is a function for creating multiple loops. It retrieves a list of latest posts or posts matching criteria.
0
votes
1answer
24 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
17 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 ...
0
votes
1answer
17 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
35 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
23 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
18 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
42 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
15 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
17 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
50 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
37 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
32 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
73 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
35 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
42 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 ...
0
votes
0answers
66 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
32 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
60 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
204 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
41 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
50 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
39 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?
0
votes
2answers
98 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;
...
1
vote
1answer
124 views
WordPress get posts by date without query_posts
I'm want to get posts from the last 30days in a sidebar but I don't want to use query_posts, is there a way to achieve this with the get posts function?
0
votes
1answer
84 views
Count number of posts of current month
I am trying to echo the number of posts for the current month from all categories but it isnt working.
<?php
$month = date('m');
$year = date('Y');
$countposts = ...
0
votes
2answers
61 views
get_post_custom_values not working
I have made a custom template to show the posts in "Products" category in a single page.I have some custom fields.I need to show the values of the custom fields in the page. I have used the ...
0
votes
1answer
42 views
how to display all images from their siblings/ from same parent?
I need to know how to display all images from the current page siblings.
for eg. I got two parents (Hockey and football) with children.
In all this children I got one or several images attached (I've ...
0
votes
0answers
12 views
Get template part with Except [duplicate]
I am using
<?php
wp_reset_query();
query_posts('posts_per_page=20&post_type=post&post_status=publish');
get_template_part('index');
?>
in single post bottom. Its ...
0
votes
1answer
74 views
Conditional get template part
My index page look like this...
<div id="ad-id">google ad code goes here </div><br />
<div id="post-id">My posts are goes here</div>
I use
...
1
vote
1answer
206 views
query_posts() vs get_posts() multiple loops [duplicate]
I have a template which initially had one single loop and it was using query_posts, I added 2 more loops using the same method, However after reading allot about these it was concluded that I shall ...
0
votes
1answer
30 views
Posts being viewed
I am looking for a way to list posts being viewed but I can't find anything online.
Is it even possible? I've seen some websites that have these loops, "What other readers are currently reading".
...
1
vote
3answers
205 views
Check If posts exist in custom post type category, outside of loop
I'm building a navigation, outside of the main loop, that includes drop downs. I have a custom post type called 'Events', that has its own categories. I would like there to be a drop down if there ...
0
votes
1answer
21 views
How to retrive the text : No movie by this actor
Hy, im building a cinema site, in movie page i have a Custom Field that link's the actor page, when i add a movie and i link the actor, on the actor page i get the movie, now the problem is how can i ...
0
votes
1answer
189 views
Sort get_children by menu_order
I'm using the jQuery Carousel Gallery and unfortunately it's not working with WP's new v3.5 gallery ordering. When the client drags to rearrange images, those changes are not reflected in the ...
1
vote
1answer
94 views
get_posts meta_value is serialized array, how can I grab specific posts with combination of meta_key/meta_value[0]->is_featured?
I've a postmeta key saved in DB: mediSHOP_product_extras
It's value is
Unserialized: Array ( [0] => Array ( [is_slider] => 0 [is_featured] => 0 [in_stock] => 0 [video_url] => ...
1
vote
1answer
133 views
Getting movie and serial on actor page
I'm building a cinema site, I came with a problem, let me explain:
Movies- are stored in Post's
Actors- are stored in Post Type - persoane ( taxonomy= lista)
Serials - are stored in Post Type - ...
2
votes
2answers
121 views
Why Does get_posts() Return an Empty Set?
I'm writing a custom plugin that is initialized at init. This plugin is trying to query for some custom post types already stored in the DB.
Here's my code:
$args = array()
$myposts = get_posts( ...
0
votes
2answers
97 views
Working with get_posts parameters/arrays/strings
I'm transitioning all my query_posts queries to get_posts after a lot of research about how bad it is for performance. My solution is get_posts but working with it is confusing me.
Here is what I ...
0
votes
1answer
214 views
Combine query_posts() and get_posts() into single query
I am creating a site which uses normal posts for a blog and the a custom post type for events(generated by the events plugin). I have successfuly used different queries to grab both but I want to ...
1
vote
2answers
37 views
is there a better way of combining this?
Hoping someone can point me in the direction of writing this in a more succinct way.
I'm working on my website, and want to display a total of 5 posts from the category 'general wonderings'.
The ...
0
votes
1answer
74 views
Getting post by specific date in Advance Custom Field
How can i get movies there are today in cinema, for example my code display the movies in time that shoud apear 16 January,17 January..., how can i display only the movies in this day.
Ex: today is ...
1
vote
1answer
139 views
How to get all children and grandchildren of a hierarchical custom post type?
I need to get all sub-posts of a specific (root) parent id.
get_posts( array( 'numberposts' => -1, 'post_status' => 'publish', 'post_type' => 'microsite', 'post_parent' => ...
0
votes
1answer
78 views
get_posts in meta box dropdown not showing latest posts
I’ve got a metabox I set up using WPAlchemy that allows authors to add a link to an associated post. It’s been working fine for months but now for some reason the dropdown with the appropriate posts ...
0
votes
1answer
75 views
List random posts on single page in the current category
I would like to show 8 random posts on single page from same category.
<?php
global $post;
$categories = get_the_category();
foreach ($categories as $category) :
$args = array( ...
0
votes
2answers
176 views
What should I use, get_posts or wp_query for less CPU load?
I have a blog and on the main page are 3 blocks of posts. So, I get these posts with "get_post" and I have 3 similar codes on page:
global $post;
$args = array( ... );
$myposts = get_posts( $args );
...
3
votes
2answers
116 views
Very slow query
This query works, but it takes upwards of 20 seconds to run on a Quad Core dedicated server... How can I optimize this?
$slides=get_posts(
array('post_type' => 'any', 'numberposts' => 5, ...
0
votes
1answer
98 views
Why posts array is empty?
I try to get posts that either do not have a custom field set or if set have a value not like a given parameter.
Here is my code:
$args_included = array(
'numberposts' => 1,
...
0
votes
1answer
119 views
Query custom posts of logged in user only
I have a custom post type setup called website I thought using the code below would display only the logged in users posts but it's displaying all of the custom posts even those not belonging to the ...
2
votes
0answers
285 views
Get attachments (get_posts) and WP 3.5 new uploader
I'm using get_posts() to get attachments from the post and use it in the slider. The issue is new uploader doesn't have that "Gallery" tab which was perfectly suitable for this. It also seems to be ...
0
votes
1answer
332 views
List all posts in a category with query_post() function
I'm a C programmer, konw little about PHP. I built a Blog with wordpress.
Yestoday, I try to create the page www.abc.com/server, this page would list all posts which belong to server category.
I ...

