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

2
votes
0answers
487 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 ...
1
vote
0answers
20 views

Query to only return the 2 newest post attachments (images)?

How can you make a query that runs through all posts in a category and outputs only the 2 newest image attachments (most posts in the category have no attachments)? My current query is like this: ...
1
vote
0answers
45 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) { ...
1
vote
0answers
37 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). ...
1
vote
0answers
109 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"); ...
1
vote
0answers
139 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
0answers
123 views

Any way for get_next_post() to use the actual post order instead of publish order?

I'm currently using get_next_post() and get_previous_post() to get their ID so that I can permalink my next/previous buttons for a custom post type. I'm also using a wordpress plugin called "Anything ...
1
vote
0answers
181 views

Posts are not showing up on particular category

On my website, post are not showing up when I navigate to http://www.domain.com/category/category-name/ but on wordpress dashboard, I am able to see the actual number of post under that category. ...
1
vote
0answers
477 views

Show all posts using the template page and the loop?

I am trying to make a template page that would display all posts from all categories, in short - every post added to my website. I was googling around and found out that it can be done by using The ...
1
vote
0answers
52 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
0answers
20 views

get_posts ( $args) failing when called by AJAX

Here's my code: function ajax_test(){ $default_workout_category = 61 //Hardcoded category for testing $args = array( 'category' => $default_workout_category, 'orderby' => 'title', ...
0
votes
0answers
14 views

Decrement term in for each

So I am catching custom posts in wordpress by for eaching my custom terms. To get a post from the next term in the loop I use $terms[++$key]->name and it all works fine. However when I want to do the ...
0
votes
0answers
16 views

Get Custom Post Type posts on normal edit-posts and pass to TinyMCE

I am following a tutorial for adding a dropdown list in tinyMCE editor. In the end I would like to have a Select list similar like it is in this image , but populated by post titles from Custom Post ...
0
votes
0answers
24 views

Getting posts for a category

I have a menu made up of categories, click a category shows the users list of articles beloging to said category. However I seem to have stumbled across a problem if a post belongs to 2 or more ...
0
votes
0answers
35 views

'exclude' argument is not working with get_posts for a custom post type

I'm trying to use get_posts to get a random list of customPostTypes but I want to exclude some id's. I already try the query with the following options: Current) 'exclude' => array(622, 621) --- ...
0
votes
0answers
27 views

user_has_cap filter crashes site when doing get_posts()

I can not understand why the site is crashing when adding this block of code: function demo_function( $capabilities ) { global $pagenow; if ( $pagenow != 'post-new.php' ) { ...
0
votes
0answers
29 views

Ordering Posts by parent category, name ascending

I am currently creating a theme, and I have 2 parent categories: Budget and Brand. On home.php, I want to order all the posts ascending by their sub category name without showing the category title. ...
0
votes
0answers
78 views

Display custom post type AND posts from a certain category

As the topic says I want to show posts from one category (band-news) and posts from a custom post type (artist) in the same loop. I got this but as you can see it want do as I wish: <?php $posts ...
0
votes
0answers
27 views

Search on Category and BETWEEN custom meta field

Background I am building simple car theme where I want to review cars, however, I'm really struggling with my search implementation. I have added a couple of custom meta fields to the post including ...
0
votes
0answers
67 views

Posts not showing when category is clicked

I have a site: microman.be. The blog was imported by Blogger Import tool. All posts are visible, on the blog page too. When I click on a category in the blog sidebar an empty page turns up. The URL ...
0
votes
0answers
128 views

How to get post content by get_posts function?

I'm newbie at Wordpress and now I need to get the post content in events plugin. I have simple array: $event = get_posts(array( 'name' => $events_array[$i], 'post_type' => ...
0
votes
0answers
34 views

How to Create Random post once in a day

Hello Guys I am having issue with the code i found here I wanted to add specific custom post type to be randomized once in a day and i used the code i found here but that repeating the content on ...
0
votes
0answers
78 views

$wpdb->query(update) not working as supposed when passing GET request in the where clause

I have made a table 'wp_mostfavourite' in wordpress database, it has got three fields, 'serialno', 'postid', 'counts'. The 'counts' is supposed to be increased by 1, whenever the following query is ...
0
votes
0answers
21 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
0answers
52 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
38 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
34 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
117 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
0answers
36 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' => ...
0
votes
0answers
21 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
0answers
48 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 ...
0
votes
0answers
205 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
155 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
50 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
0answers
135 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
2k 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 ...
0
votes
0answers
22 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
0answers
176 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
0answers
141 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
0answers
127 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
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
0answers
32 views

Get Posts by tag from a custom taxonomy

I have a custom post type called product, which have two custom taxonomies named as product_tags & product_categories. In My Product Categories archive page, I am listing tags. My requirement ...
0
votes
0answers
264 views

Custom query not working in plugin admin page

I'm not sure what I am doing wrong, but I cannot use get_post, get_posts or WP_Query in my plugin admin page. I can use get_user_meta, and get_userdata, so I'm a bit confused as to why I cannot use ...
0
votes
0answers
179 views

A Depth Like Parameter For “get_posts”

Wordpress has stumped me for the first time in a very long time. I am trying to limit the depth of a get_posts call in my template. I want to get children but limit it to a depth of only 3 as I am ...
0
votes
0answers
145 views

Getting post content within wp_nav_walker

I have a custom walker set up designed to add content into the nav menu. The problem being that it is not pulling the content. The post object returned by the get_post/get_page has an empty ...
0
votes
0answers
886 views

Why WP_Query in functions.php is not working when get_posts works?

I have following code in my functions.php. When I try to add new post_type (e.g. post,lawyers) it fills excerpt,slug (this affects in permalink structure), other metaboxes from first post of lawyers ...
0
votes
0answers
318 views

How do I get post attachments in menu_order in Wordpress?

I'm struggling to get menu_order to work for images attached to a post. I am trying to pull all of the images attached to a specific post in the order specified via the drag-and-drop interface in the ...
0
votes
0answers
242 views

Post per page not working

I have 2 parent categories are app and game. Beside them has child categories. My code get 6 post from 2 parent categories with orderby post date and order DESC, but post per page not working. Please ...
0
votes
0answers
153 views

How can I give Wordpress child custom post type the same title and slug as its parent?

I have two custom post types, one is the child of the other (the parent is more of a modal post). I want the child post to inherit the same title and slug as its parent. I've tried to use the ...
0
votes
0answers
172 views

404 Error is showing when open page posts

I just downloaded the video theme from templatic, when i am displaying videos from the thumbnail, it shows 404 error Link to the page It is not showing the video, how to avoid this problem and show ...