get_posts() is a function for creating multiple loops. It retrieves a list of latest posts or posts matching criteria.
2
votes
2answers
296 views
List most recent image uploads, but only for specific custom post type
I can get a list of the most recent image attachments like so:
$attachments = get_posts( array(
'post_type' => 'attachment',
'posts_per_page' => $number,
'post_mime_type' => ...
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 - ...
1
vote
1answer
387 views
get_the_content(“more…”) returns full text
I'm creating shortcode [latest_post] and want to show post date, title and short content. (content has "more" separator). Here is code:
function shortcode_latest_post() {
global $post, $more;
...
0
votes
1answer
26 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
25 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
207 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
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
1answer
43 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
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 ...
0
votes
1answer
104 views
Efficiently loop over huge number of posts
I want to loop all posts to do some processing, but one of my concern is there are many posts and it might used up my memory, so I want to loop posts with offset, something like paging.
e.g.
$posts ...
0
votes
1answer
395 views
get_posts by id not working
I have the following code:
global $post;
$current_post = $post->ID;
$array=range(1,$current_post);
$posts = get_posts('numberposts=5&post__in=' . $array . '&category='. ...
0
votes
1answer
69 views
Displaying posts on Homepage
I am wondering how to add a column to my homepage that shows the five most recent posts from the blog page located under the "Latest News" heading.
Here is the link to my development site.
...
0
votes
1answer
31 views
How do I display the index position of a post from a custom post type?
So I have a custom post type (ex. songs) and have a few posts that I created for this post type.
I want to display them on a webpage in order (ex. 1, 2, 3, ...). How do I get the index position and ...
0
votes
1answer
84 views
Execute PHP function inside the admin area
I want to ask if there is a hook for executing php inside the admin area, my problem is I'm trying to do the get_posts wordpress function inside a popup frame using the thickbox jQuery plugin, using ...
0
votes
1answer
287 views
Can't sort get_posts by post_mime_type
I'm trying to run a query to get all attachments and I'd like to sort by the post mime type. This query isn't working. Any ideas?
$query_args = array(
'post_type' => 'attachment',
'numberposts' ...
-1
votes
1answer
371 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?
2
votes
0answers
286 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 ...
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(
...
1
vote
0answers
229 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 ...
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
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
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',
...