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

Secondary ordering and order DESC not working when using meta_value_num

I have this query: $args_members = array( 'posts_per_page' => -1, 'post_type' => 'team_member', 'post_status' => 'publish', 'meta_key' => ...
0
votes
1answer
17 views

Loading post template that contains a nested loop with ajax

I'm currently working on a project where I'm loading a post with ajax. I'm using get_post() to get the post, setup_postdata() to setup the post data, and get_template_part() to load the template ...
0
votes
3answers
22 views

Order post by taxonomy

I am trying to write a get_posts() query to retrieve 7 posts per page. The retrieval of these posts are based on 3 different tags, "Featured","Highlighted", and "News". Now the "Featured" post take ...
0
votes
1answer
21 views

Why does get_posts only show results for Admins or logged-out users?

I use a get_posts() call with these arguments: array(6) { ["include"]=> string(14) "1633,1634,1635" ["post_status"]=> string(3) "any" ["post_type"]=> string(10) "attachment" ...
0
votes
1answer
27 views

numberposts not responding to wp_reset_postdata()

I am working on a loop where I want the content (from 2 separate categories) to be displayed like this: 1 large format post, 1 random product, 2 small format posts, 1 feature post ...repeat. In order ...
0
votes
0answers
33 views

How to search posts by title, id and author? [duplicate]

i am getting the details from a custom search with the below query from a parameter $_REQUEST['search'] in the URL $custom_args = array( 'post_type' => 'post', 'posts_per_page' => 5, ...
0
votes
1answer
16 views

get_posts array 'between' not behaving

if I make the query of $apartments = get_posts( array ( 'post_type' => 'apartment','meta_key' => 'bedrooms','meta_value'=> array(4,12) , 'compare' => 'BETWEEN' , 'type' => ...
1
vote
0answers
19 views

Pagination with an array of post objects?

I am curious, I have the following code: foreach ($this->networkBlogs as $siteBlog) { switch_to_blog($siteBlog['blog_id']); foreach (get_posts() as $postObject) { ...
0
votes
2answers
25 views

This wp_query will not return any posts and only seems to work with post_status inherit?

I'm having difficulty returning a list of posts. This file is contained in a plugin folder (ultimately I want to have a cron job just run the script here to delete posts with invalid urls in the given ...
0
votes
1answer
17 views

Even with PHP plugin get_posts not working in widget area

I have the following code in a template, it and displays images form a custom field: <ul class="about-us-grid"> <li> <?php $posts = ...
0
votes
0answers
21 views

Group by multiple taxonomies and hide empty loops

This was helpful for grouping, but didn't quite solve another issue I'm dealing with: Display category posts grouped by taxonomy I've got two different variables to sort through. 'product_type' and ...
0
votes
0answers
28 views

Querying on a custom post type without tags returns no posts

A theme I'm working on contains a custom post type, "help_question", which is declared as such in functions.php add_action( 'init', 'create_post_type' ); function create_post_type() { ...
0
votes
0answers
11 views

Query if audio attachment AND/OR custom field

I've been trying several things but to no avail... Searched, maybe not good enough though! I have posts that either have an uploaded audio file AND/OR has a Soundcloud link (which is a custom field). ...
0
votes
0answers
13 views

URL rewriting taxonomy term

I'm trying to find solution for the following hours now and i don't know if this is applicable. I have 1 Custom Taxonomy "Years" for Post Type "Post (default)". The taxonomy has 2 Terms: "2014" and ...
0
votes
0answers
40 views

Pre_get_posts meta query value serialized array using multiple URL parameters

Using the 'pre_get_posts' action I'm looking to return all posts which match multiple URL parameters by defining the meta_query. For example: example.com/?size=large,small&options=green,blue,red ...
0
votes
2answers
31 views

How to Retrieve Post ID of another page

I have a post and payment page each posts contain a payment form I want to know how I can retrieve the data to I can execute and publish where the post payment came from on payment form submit ...
0
votes
1answer
46 views

How to get the intersection of two terms both from different custom taxonomies

I have a custom post type listing Then there are two custom taxonomies job_listing_region job_listing_category On home page i have links to job_listing_category like shop,eat,stay etc. and job ...
0
votes
1answer
16 views

Get posts in between specific ID's

I want to get the posts from within specific ID's ( 10 - 15 ), just like we do in SQL select * from employees limit 10 , 20 ; I wanna get in this Wordpress posts.
0
votes
0answers
22 views

Weekly most viewed posts

My code returns most viewed posts. How can I show weekly most viewed posts? Here is my code: $args = get_posts( array( 'meta_key' => 'post_views_count', 'orderby' => ...
1
vote
2answers
65 views

Display latest x posts from all categories in Custom Post Type/Taxonomy

I am attempting to display the latest x posts from all categories using a custom taxonomy called 'case-studies' in WordPress. I have managed to output all the category names as heading links I have ...
1
vote
1answer
68 views

Get posts from specific taxonomy term

I have nhl news website and I have taxonomy for each season (ex 2014-15) Taxonomy in functions: function wptp_register_taxonomy() { register_taxonomy( 'season', 'post', array( ...
0
votes
1answer
63 views

Mathematical operations on custom field values? (updated)

I'm attempting to write a function, run by a cron schedule at midnight every night, that will subtract 1 from the integer value of a custom field. It will function basically as a countdown timer for ...
3
votes
1answer
59 views

How to order by post_status?

I'm using get_posts() like this: $posts = get_posts(array('orderby' => 'post_status')) which is not possible cause it's not in the allowed keys in the parse_orderby() method How to get around ...
0
votes
2answers
78 views

Wordpress get_posts by category

I have the following bit of code: $args = array( 'posts_per_page' => -1, 'category' => 7, 'orderby' => 'name', 'order' => 'ASC', ...
1
vote
1answer
24 views

Modify theme to get page excerpts on front page

I am trying to modify this theme so that the Latest News section shows excerpts from 3 specific pages (for example, /page1, /page2, /page3) instead of 3 most recent posts. This is the relevant code ...
1
vote
1answer
80 views

Display the_content on click jquery

I'm trying to display the_content of a post on click. the problem I'm having is that it display always display the same content. I mean by on click on read for post A, it display the_content of post ...
0
votes
1answer
42 views

Memory issue with get_posts( ) function

I got a fatal error in existing code, when I debug deeper I found that it was coming from bellow line. get_posts( array("posts_per_page"=>-1) ); Can anyone explain why is that and how to ...
0
votes
0answers
14 views

Filter to set a variable once a post is populated?

I'm working on a playlists plugin. The playlists are just custom post types; and they have extra properties I need to populate once a 'playlist' post is loaded. So the idea would be to have a ...
0
votes
1answer
43 views

Reset Wordpress Post Query to default

i am in a situation, i am creating a custom wordpress theme but i am stuck over something. in my index/home page, firstly i am displaying 6 posts by category like below <?php $posts = ...
0
votes
0answers
40 views

Is there a way to sort the results from “get_post_type” alphabetically?

I am trying to generate a list of my custom post types for use in a template. I have successfully managed to output the list, but unfortunately they are in order of creation and i would like them ...
1
vote
0answers
44 views

How to find a post using XML-RPC without knowing ID

I'm using the following function to retrieve individual posts from an external server using the WordPress XML-RPC Post API: public function get_post() {      include("lib/xmlrpc.inc"); ...
0
votes
1answer
52 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
59 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
27 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
51 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
56 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
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
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
139 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
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 ...
0
votes
0answers
75 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
486 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
113 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
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 ...
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
60 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
251 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. ...