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

Using get_posts structure for a specific field [on hold]

Situation I have a custom post type named Packs and another custom post type named Hotels. In the Hotels CPT I publish hotels information, like name, amenities and services for many hotels in the ...
0
votes
0answers
29 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 ...
1
vote
3answers
49 views

Can I set and show “important” post in my blog?

I have the following doubt related to the WordPress posts showed in the home page. I know that in the home page I can show the latest published posts. But can I also show (before the latest posts) a ...
0
votes
1answer
23 views

one get_posts to return a number of custom posts for each meta value

I have setup a custom post 'product' with a custom field cf_type. I wish to have one get_posts that will return 20 total products, 10 products with cf_type: fog and 10 with cf_type: gof. Is that ...
0
votes
0answers
20 views

Get products from specific product type with specific post meta [closed]

I'm making use of WooCommerce and another plugin called 'Post Expiration Date', which basically adds a meta value to a post with a date value. In WooCommerce I have a specific product category, ...
0
votes
2answers
24 views

How to get latest page (not post) of User and display the content

I've been trying to get the latest Page, not post, by author ID and display it on a page. The reason it has to be a page and not a post is that the user will only be posting one page and a whole ...
0
votes
1answer
33 views

How to create content automatically when a post is published?

Goal: Ability to automatically create content in WordPress posts/pages. Goal Details: When a post is created/published, it will automatically create or configure content based on the base data inputs ...
0
votes
0answers
33 views

How to use get_categories results called in header.php on the homepage as well without calling the database twice?

I have a Wordpress blog with multiple categories and I have to display the last two posts of certain categories(not all of them) in the header. This is so as to have this information available ...
0
votes
2answers
26 views

Sort order in get_posts [closed]

I've created a custom template for a client. This is going to be a multilingual site setup on a Multisite install. As you can see under each category letter, the posts start out in alphabetical order ...
0
votes
1answer
25 views

Help to cleanup this code

I am trying to change my attachment page link yo example.com/photos/attachment_ID/post_name/attachment_name can you tell me how to call the parent post name function wpd_attachment_link( ...
0
votes
0answers
17 views

how to get wordpress categories list with thumbnails?

i am trying to get thumbnails list with their thumbnails images .i tried code below but it only gives categories list . i know there a could do using feed_image but i can't figure out how to do it ...
0
votes
1answer
69 views

Change attachment inside the_content using filters

I am in search of a snippet or function that will filter the embedded images inside a post to a custom size I have defined in functions.php. Here is the scenario: A client uploads and add any ...
0
votes
1answer
21 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
1answer
23 views

Exclude parent category when getting category posts by slug

I have the following category layout: Resources -- Documents I want to list the posts in the documents category, and have the following code: $args = array( 'posts_per_page' => ...
0
votes
1answer
21 views

what is the maximum number of post a wordpress loop can work with?

what is the maximum number of post a wordpress loop can work with? how many post can i display with 'posts_per_page' => -1? ive got 50,000+ pages and I want to sort through them, but I just get ...
0
votes
2answers
38 views

Display post's description and caption

I am trying to get and display 5 featured posts. To achieve this target I have an offset of 5 recent posts. I have successfully fetched the posts' id's and images, but I failed to get every post's ...
0
votes
1answer
23 views

the paged param is allways 0

I am listing a custom post_type called ad using get_posts wich works fine, Problem that I have is that I am not able to read the paged param, wich I need in order to enable pagination, The thing is ...
0
votes
0answers
26 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
2answers
47 views

show posts in different styling

I would like to show categories in the front page with different behavior: categories to show posts in two styles [Three posts having the same style and then another two with the same style] ...
3
votes
2answers
192 views

How do you get posts by meta_query using the JSON API plugin?

I would like to get post with an API method using a kind of meta query. I have 2 custom fields "place" and "dayoweek" and I want to retrieve via API call all the post that have some values for this 2 ...
0
votes
1answer
31 views

get_post_meta slowing down my page load (in a plugin)

I've been working on this project where I need to load events (custom post type) and a whole bunch of meta data for every event. The problem is that page loading times are getting longer and longer ...
0
votes
0answers
24 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 ...
0
votes
1answer
53 views

Secondary Query Is Breaking Main Query

I registered a Custom Post type called "quote" and I am trying to show a single random quote on every page of my Wordpress site. I'm pulling out a single quote with the following code: $args = ...
1
vote
1answer
40 views

Get posts from taxonomy URL

How can I get the posts from a custom taxonomy using the URL to determine which taxonomy term id is being shown? I tried to get posts via a category using get_category_by_path which returned false ...
-1
votes
1answer
36 views

show custom post's post in two different divs [duplicate]

I have created a custom post type. For that I have used this code add_action( 'init', 'broker_post_type' ); function broker_post_type() { register_post_type( 'new_broker', array( 'labels' ...
0
votes
0answers
26 views

Issue with recent custom post type permalink

I'm using the following code in my footer to get the latest posts from specific custom post type. <?php //WordPress loop for custom post type with taxonomy $my_query = new ...
0
votes
1answer
27 views

Wordpress plugin: Getting posts where checkbox selected

I would like to have a plugin where I could work with all post data from posts that have a selected checkbox.. To get all posts is simple with the get_posts( $args ); function... But how to add a ...
0
votes
1answer
48 views

Custom loop in addition to default on archive page

I'm trying to create an interface on the admin that will allow our authors to select top resources to place as an aside on our archive page. I'm trying to add a loop in addition to the original query ...
0
votes
2answers
105 views

Auto-change Post Status on First Page Load

I have created a number of custom post statuses using the EdiFlow plugin. Now, what I am trying to do is, if the contribter visits the post edit page and the post status is "assigned" to automatically ...
0
votes
1answer
73 views

get_posts works but new wp_query doesn't

I was told that get_posts is a very bad function to use that that making a new WP_query is absolutely better. My problem is that my get_posts code works but when I tried turning it into a WP_query, ...
0
votes
2answers
67 views

Retrieving 3 latest post from each of 5 different custom post types

I have 5 different custom post types. I am showing 15 latest post from them on my home page using following query: $query = new WP_Query( array ( 'posts_per_page' => 15, ...
0
votes
1answer
35 views

get_posts not honoring post_status

I have a custom post type 'license' with custom post statuses 'active,inactive,cancel,expire'. However when I run a get_posts query to get only posts with active status it returns all the posts ...
1
vote
1answer
71 views

What's wrong with my date_query?

It's WordPress 3.9 "Smith". I'm trying to implement a new Archive page as per the suggestion of @Milo. $categories = get_categories( $cat_args ); //it's NOT important for the Q, as it's fetching ...
1
vote
1answer
46 views

How to get the post content from a category on my homepage

I'm trying to get posts with a specific category to show in a box on my home page. But ive only been able to get one post on my homepage. How can I make this work in the code below? With getting the ...
0
votes
0answers
34 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
2answers
45 views

Query posts by a type and another type only if post is in specific category

I have a featured post type and a reviews post type. I would like to include reviews of a certain category (I use categories from the posts type) as well. How could query args be crafted? A crude ...
-1
votes
1answer
36 views

Can't get Category link inside get_posts

I created a simple function to display the latest posts. Inside the function there is a conditional to display the post category. I found that to display the category name, using $category = ...
0
votes
1answer
42 views

How to get post content from an array of ids?

How do I get post content if I have an array of id's. Basically, I have a function that get post content if you provide an ID. but it doesn't work if I have an array of id's. My function is: function ...
-1
votes
1answer
32 views

how to ask if in two categorys inside if

I'm new two wordpress so sorry in advance if this question might be very basic. Depending on which category a post is, I do some script things and I ask inside the loop in this way: <?php if ...
1
vote
0answers
42 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. ...
0
votes
0answers
225 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
21 views

Custom Shortcode that includes filtering by tag

Within a custom shortcode, how do I filter the posts that come back from get_posts() such that only posts with Tag = "xyz" are returned? Here is what I have in my shortcode currently: $args = array( ...
-1
votes
1answer
137 views

posts_per_page - Repeats only first posts 'post__in' array

This question correlates with a previous question I was able to solve here: http://wordpress.stackexchange.com/a/137929/28389 I am using an array for 'post__in', and I am able to run this no problem. ...
0
votes
2answers
120 views

get_posts() returns all posts rather than the ones specified with 'post_author' =>

I want to retrieve an array with the posts of a certain user for a custom post type category. However, get_posts($arg) returns ALL posts of this custom post type, although I specified the post_author ...
0
votes
2answers
256 views

How to use Wordpress Conditional Tags in get_posts foreach loop

I have a page which has a jquery tab function to output the list of pages that are the children of this page (Bio, Archives, Contact). However I am trying to make a conditional in the foreach loop ...
0
votes
1answer
105 views

Get total posts found, but while using limit for pagination? get_posts

I have a ton of posts that I need to get the IDs of based on a custom taxonomy search. As it's used for pagination, I also need to get the total posts without a limit, but I'm not sure how. I use the ...
0
votes
0answers
15 views

return custom taxonomy terms in post object

How would I go about returning the custom taxonomies in the post object with WP Query or with get_posts for that matter. yes, I know I can loop over my query and use get_terms or a number of other ...
0
votes
1answer
102 views

get_posts ignoring 'category' and displaying all posts

I'm going a bit crazy on this one. I'm trying to display a list of posts in a category on an Admin page in a plugin I am writing. The following code works fine on my dev server (OS X/Apache): $args = ...
0
votes
0answers
121 views

get_posts multiple criterias

Hi I'm trying to get only posts from a certain category, but also all other posts that have a certain field value. for example: all posts in the "News" category. but also all posts marked as featured ...
0
votes
3answers
77 views

How to show more than 5 posts?

I am running code that shows child categories, and all posts in the child categories. But if there are more than 5 posts in a category, only the 5 newest are shown. How can I show all, or at least ...