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
0answers
86 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
1answer
60 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 ...
1
vote
3answers
2k 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
0answers
14 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
145 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?
-3
votes
1answer
431 views

Get all posts without tags

I'm working with a tag plugin. Is there a WordPress way to get_posts or query all posts that have no tags? EDIT I had already queried the WP Codex, search Stackexchange and Google for a related ...
0
votes
0answers
76 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
1answer
424 views

get_posts() forcing ignore sticky posts on main loop

I have a custom query using get_posts() that besides ignoring sticky on its main query, ignores sticky posts on main loop. Reading around I've found that get_posts() have some trouble with sticky but ...
0
votes
0answers
488 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
115 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' ...
4
votes
1answer
7k views

Why get_posts are only showing five posts (retrieved by assigning a category to them?

Here is the link http://www.brianfunshine.com/voice-work/voice-page/ This is the code: <?php /** * Template Name: Voice Page (Two Columns) * @package WordPress * @subpackage Twenty_Ten * ...
-1
votes
1answer
79 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 ...
1
vote
1answer
428 views

AJAX pagination offset 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
13 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' ...
2
votes
1answer
61 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
18 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
39 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
72 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
255 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
27 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
27 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
101 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" } ...
2
votes
2answers
6k views

Using get_posts with arguments found in meta keys

I am using get posts, but I need to refine the query based on posts where a certain meta_key has a certain value. Something like this <?php $reviews = ...
0
votes
0answers
109 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
106 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 ...
86
votes
4answers
67k views

When to use WP_query(), query_posts() and pre_get_posts

I read @nacin's You don't know Query yesterday and was sent down a bit of a querying rabbit hole. Before yesterday, I was (wrongly) using query_posts() for all my querying needs. Now I'm a little bit ...
0
votes
0answers
105 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
90 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
97 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
261 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
3k views

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
111 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
28 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 ...
0
votes
2answers
230 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
94 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
148 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
51 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
143 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; ...
4
votes
1answer
15k views

get_posts - get all posts by author id

I want to get all posts by certain author id (current user). Later, I want to pick the first post made by this user (ASC). I guess I do not use the right arguments in get_posts, am I? ...
1
vote
1answer
6k views

Sort “get_pages” by menu order not ordering

I'm using this bit of code to generate a page full of items but they won't sort into the menu order, any ideas as to why? <?php $pages = get_pages(array('child_of', 'menu_order')); ?>
0
votes
0answers
16 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
123 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
2answers
63 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
70 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 ...
5
votes
3answers
3k views

Regenerate Slugs From Title of Posts

is it possible to regenerate the slugs programmatically after changing the titles of the post? Numerous post titles were updated and the slug was not updated with the title so I need to regenerate all ...
3
votes
3answers
19k views

get_posts assigned to a specific custom taxonomy term, and not the term's children

Say I have the following taxonomy terms: Term 1 Term 1.1 Term 1.2 Term 2 Term 2.1 How can I get only posts that are assigned to Term 1 and not include those that are assigned to Term 1.1 or ...
0
votes
0answers
29 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
207 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
36 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
1k 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', ...