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
18 views

Show excerpt if no title in admin view

Usually my posts do not have a title, so in the admin view it always says "(no title)" wherever the title would be shown. So I am wondering how I could hook into that view function. I would like to ...
0
votes
1answer
15 views

How to remove 'GROUP BY' from SQL query produced from get_posts?

Wordpress, Archive Cateory page. From default WP_Query->get_posts() we are getting something like this: SELECT wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = ...
0
votes
2answers
20 views

get_post orderby not working in plugin

Please take a look at the loops below, I'm having issues trying to order the attachment by title, name, and modified. <?php foreach ($instance['data'] as $id) : ...
0
votes
1answer
13 views

meta_query date and time comparisons

I am trying to query my posts against the value of 2 custom meta_keys... '_mdjm_event_date' formatted as Y-M-D (2015-05-13) '_mdjm_event_finish' formatted as H:i:s (23:35:00) Here is my query... ...
0
votes
0answers
19 views

How to get only specific fields from get_posts?

I found this in a display widget plugin thinking it works fine get_posts( array( 'post_type' => 'page', 'post_status' => 'publish', 'numberposts' => -1, 'orderby' => ...
0
votes
0answers
17 views

Ajax request with get_posts

I am new to wordpress development. I basically am pulling information from a custom post based on a category. What I want is to load more post when a button is clicked. I've searched for hours but ...
0
votes
0answers
9 views

Popup panel is only displaying 1 entry ignoring all others

I have a popup panel being used for when someone clicks on view bio it will display their bio along with their name and headshot. As of right now I have four members being displayed M1 M2 M3 and M4. ...
0
votes
3answers
31 views

get_posts with multiple categories

If I do a get_posts() with category set to 1,2 I will get all posts in category 1 OR 2. If i want all posts whit both categories, that is 1 AND 2, how do I make that request?
0
votes
1answer
26 views

How to get the current user post and it's ID?

I have a site setup so users can publish a post via the frontend, what happens is, there post is posted as a status, 'Pending Review, in a custom post type. How can i get the post ID for this ...
0
votes
0answers
26 views

Avoid changing menu query with suppress_filters => false

I recently had to change qTranslate for qTranslate X since the former is not being updated. This broke my menu and after searching I found it was because qTranslate X sets suppress_filters to false. ...
0
votes
0answers
54 views

How to get custom post type title, excerpt, thumbnail and permalink by post ID?

I have to generate several "loops" to get the title, excerpt, thumbnail and permalink of a custom post type 'charity' by post ID, because I will have multiple posts (charities) I need to target with a ...
-1
votes
1answer
58 views

tax_query not working properly with get_posts

Here are my args: $args_home = array( 'post_type' => array('news', 'jobs'), 'posts_per_page' => 12, 'meta_query' => array( array( 'key' => '_thumbnail_id' ...
-1
votes
1answer
34 views

Query custom post types by meta field in a term from custom taxonomy

I need to retrieve all custom posts that have terms from custom taxonomy assigned to them. To be more precise: There is advertisers_cats post type that has terms assigned from custom taxonomy ...
0
votes
1answer
11 views

Display posts from catagories

I am using an option framework. This saves catagory ids.To get ids I have done $cat = $atts['post_catagory']; var_dump($cat); The var dump result is array (size=2) 0 => string '1' ...
1
vote
1answer
35 views

date_query not returning some posts in date range

I'm getting some very strange results with the date_query parameter of get_posts. I have a post for which: date('Y-m-d H:i', get_post_time('U', false, $postid)) returns: 2014-04-03 10:42 This ...
0
votes
0answers
15 views

Change get_posts to loop.php suitable version

I did't know that get_posts don't work with loop.php. I already have this great loop.php file and I want to use it. I created this code: $pageposts = get_posts( array( 'relation' => ...
0
votes
1answer
18 views

Get images by category

My current way of getting the images for sliders is by using the following code that works perfectly: $args = array( 'post_type' => 'attachment', 'sort_order' => 'ASC', ...
0
votes
1answer
61 views

Need help with get_posts pagination

I've been working on a wordpress site, and I'm trying to build a page where visitors can see all of the images that have been uploaded to the wordpress media gallery, regardless of whether or not said ...
0
votes
1answer
46 views

Multiple posts/pages in one page?

I'm trying to create website with index page which will have 2+ different boxs with different content generated from post or pages in WP administration. This page will be looks like this wireframe. ...
0
votes
1answer
22 views

excluding current post from get_posts

i have this block of code displayed in single.php template <ul class="cat-wrap"> <?php global $post; $categories = get_the_category(); foreach ($categories as ...
0
votes
1answer
18 views

get_posts not pulling the correct number of posts

I am using the BracketPress plugin and trying to pull all of the posts of post_type brackets so I can send a newsletter blast to everyone with their current leaderboard position. However the get_posts ...
-1
votes
3answers
67 views

Custom Post Type meta value is being saved in array, instead of just the string (as value)

So, this is how WordPress is saving my CPT meta: array(8) { ["product_id"]=> array(1) { [0]=> string(10) "abcdefg987" } ["end_date"]=> array(1) { [0]=> string(10) "02-02-2015" } ...
0
votes
0answers
55 views

How To Use get_posts & get_the_post_thumbnail Outside The Loop

This works fine within the loop but i cannot hook it outside the loop. global $post; $args = array( 'post__in' => array( 1, 5, 17, 19, 21, 23, 25, 27, ) ); $thumbnails = get_posts($args); foreach ...
0
votes
1answer
61 views

WordPress - List Sub Categories and Sub-Sub Categories, With Posts

I have the following code. It allows me to show sub categories and documents within them. The thing is, a sub category may contain further sub categories. The code below will show documents belonging ...
0
votes
0answers
55 views

Both WP_Query and get_posts returning 1 post

I am having a weird issue. Both WP_Query and get_posts returning only one result, i.e only the latest post. Never faced this before.. The WP_Query: function custom_tsr_query() { $the_query = ...
0
votes
1answer
55 views

Multiple get_posts() queries on one page

I'm building custom page template, which has some content editable through proper articles/posts. Below are those code blocks: <?php $contact = new WP_Query(); $contact = get_posts( array( 'slug' ...
0
votes
0answers
79 views

Trying to use and understand JSON API and get_posts

Me and my friend are breaking our heads to implement something. We are trying to get the results similar to function get_posts from JSON API ...
0
votes
2answers
106 views

How to access $wp_query object from array of posts given by get_posts?

I have a simple custom query driven by get_posts: <ul> <?php $args = array('post_type' => 'event', 'numberposts' => 6 ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : ...
0
votes
1answer
60 views

Function using get_posts() with tax_query not working when called from functions.php

I want to get an array of all the 'bands' in taxonomy 'types', and use the array later on in other functions etc. I have a utilities.php file that I require() in functions.php and it has the following ...
0
votes
0answers
25 views

Fetch posts list from fist CPT taxonomy term and list under 2. CPT

I have two custom post types registered. Custom Post Type: PUBLIKATIONEN with the two custom taxonomies LISTEN and AUTOREN Custom Post Type: AUTOREN Both have archives. With: <?php echo ...
1
vote
3answers
975 views

How to use the_posts_navigation for wp_query and get_posts?

WordPress have the_posts_navigation function since 4.1.0. But I don't know how to use with wp_query or get_posts. the following code is in a template file of page.wp_query method: <?php if ...
0
votes
2answers
129 views

get_posts showing only 5 posts. (nopaging and posts_per_page -1 not working)

I have this piece of code which works but it's showing only 5 posts (with custom taxonomy) where should be 7. If I hit the tag url, it shows the 7 registries, so the problem it's in this code and its ...
1
vote
0answers
56 views

Conflict with get_posts and the_content

I have this snippet in my header.php to display a slider: <?php $args = array( 'post_type' => 'post', 'posts_per_page' => 6, 'meta_query' ...
1
vote
1answer
79 views

Only showing the_date and the_excerpt for first entry in get_posts

this code below shows the titles and links for 5 posts in get_posts no problem but only displays the date and excerpt for first post... any help please? <?php $args = array( 'posts_per_page' ...
0
votes
2answers
45 views

Fetching All Posts (200+) in a Category - Performance Issues?

I want to get the IDs of the 2 previous and 2 next articles in a certain category to show them as a "related videos" playlist. I know that there are the functions previous_post_link and ...
0
votes
3answers
116 views

Paginate get related post by author function

Is it possible to get this function paged? I've tried to add previous and next links but i'ts not working... function get_related_author_posts() { global $authordata, $post; ...
0
votes
0answers
14 views

Display Children Category post and child post under it

Hi I need to display only child category post in home page and then its children title under it in home page recent posts . While doing this it displaying category children post too in home page ...
0
votes
2answers
50 views

Display all Post titles with Category and Tag

I am trying to display all posts that are in a specific category and have a specific tag. This is what I have so far but it seems to ignore the & and make it or. <?php $myposts = get_posts( ...
0
votes
1answer
48 views

Get x recent posts by author?

So I have ten authors on my site, and I want to designate a section where it shows the ten authors and their 5 latest posts in the form of the post title linking to the post. I tried using the ...
0
votes
0answers
26 views

Send POST variable with 'post_publish'

I have a custom button which triggers my page builder to load on the post.php page upon clicking it. However, I want to send a variable as well with it. Here's what I tried $('#post').attr('action', ...
0
votes
1answer
107 views

Get all posts with a certain meta key, except for one with specific title

I need to return all posts with post_test_safe == 1 and exclude one with title ="Special title" Some kind of combined meta query but haven't got anything to work. function getAllPostIdsTest(){ ...
0
votes
1answer
34 views

Worpress url parse

I want to display posts in certain category only with given tag. Problem with parsing url slugs. For example, I have category named 'Clothes': example.com/clothes/ I can get posts in this category ...
1
vote
3answers
894 views

WP Query post meta value

I'm trying to get posts which have applied the meta value trainees. $args = array( 'posts_per_page' => -1, 'orderby' => 'post_date', 'order' => 'DESC', ...
0
votes
2answers
96 views

Get posts by category name

I'm having a terrible time trying to figure this out. I've registered a custom taxonomy (clinical-programs) and like to list all the PAGES that are assigned to particular page(s).
0
votes
1answer
669 views

SELECT * FROM $wpdb->posts WHERE ID > 160

I would like to retrieve all posts and relative tag with ID greater than 160. I tried: '$args=array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 5, 'orderby'=> ...
1
vote
1answer
205 views

WP_Query post_parent parameter always returns children of current page

Well the title gives it all away... Here's the code: $args = array( "post_type" => "page", "post_parent" => $cat, // runs through a loop of 5, 128, 130 "posts_per_page" => -1 ); ...
0
votes
3answers
80 views

Re-sort get_posts query results

I have a query that pulls fields from the 3 most recent posts for a carousel: get_posts('posts_per_page=3') I need to re-order the results so that instead of it being 1, 2, 3 it is 3, ...
0
votes
1answer
112 views

XMLRPC - getPosts - How to call from remote site?

For the purpose of this question, I have two WordPress websites. Let's call them "Portfolio" and "News". Portfolio is a "pages" only website while "News" is a "posts" only website. On the Portfolio ...
-1
votes
2answers
84 views

Latest post on specific category and custom css

I'm trying to create a new home page with two columns for latest post of specific category. This the page code: <div id="left-column"> <div class="bloccorosso">News & ...
0
votes
2answers
86 views

get_posts query matches too many results

I have a query inside a function that is returning matches that i don't want, for example when the $id=116 it is also returning results where the meta_key 'funds_id' is 11687. public function ...