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

Get category ID from the sidebar on multiple pages

I'm trying to display category custom field (extra-details) on post pages outside the loop in the sidebar. The below "works": <?php $cat_id = get_query_var('cat'); if(empty($cat_id)) { //which ...
0
votes
1answer
44 views

Running get_posts within get_posts to get children of children

I have a hierarchal custom post type called “courses”. When you arrive on a course post there’s a check to see if the post has children. If the courses post has children it runs get_posts to display ...
0
votes
1answer
18 views

How do I evaluate a get_posts array with is_page?

How do I evaluate a condition in which specific pages in a get_posts() array are returned true by is_page()? Basically, I am trying to evaluate an array containing pages with a specific tag, so if the ...
1
vote
1answer
51 views

Why not yield/iterable in posts interface?

I was reading an article on the advantage of yield statements and iterables - a handy and useful thing where "the list is so large that merely creating it would consume all of the system's memory" ...
0
votes
1answer
22 views

How to get posts from a current post's month?

I want to display the titles of the post of the same month as the blog post. I tried this .. <?php $year = the_date('Y')?> <?php $month = the_date('M')?> <?php $theids = $wpdb-...
0
votes
0answers
23 views

How to use get_posts on a secondary loop [on hold]

I feel like I am missing something terribly obvious. I have set up my secondary loop and it returns the_title() and the_post_thumbnail() as expected, but I am also using the Advanced Custom Fields ...
0
votes
0answers
18 views

letting unregistered users edit or delete their custom post type only by password login

Letting the unregistered users editing or deleting their custom post type by password login only from the front end. Therefore, what I need to do is allow unregistered users to set a post password ...
0
votes
1answer
26 views

Wordpress get all post with like in terms

I have a wordpress site, which has post and custom taxonomy. I want all post of a particular taxonomy with like query. For example: Table: wp_post post_id 100 Table: term_relationship post_id ...
0
votes
2answers
19 views

Get latest posts from multiple categories

So I am using the code below to retrieve the latest 5 posts from 5 different categories. The problem is that it outputs the latest 5 posts from only the first category in the array, even if there ...
0
votes
0answers
55 views

Proper way of listing posts from custom archive with sub-categories

I am trying to create a register of things, using custom post type, named register, and custom taxonomy named register_cat. It will have categories and sub categories, something like this: Cat A ...
-2
votes
1answer
59 views

Get posts that matches specific terms of multiple custom taxonomies

I'm working on a page that show a lot of products. My structure is Product (custom post type) -->Brand (custom taxonomy) ------>Brand A (custom term) ------>Brand B (custom term) -->Department (...
0
votes
1answer
49 views

How to get post with slug and exclude categories

I want to do a query to get posts with a slug and category__not_in. Here's what I do: $query = array( "name" => "test", "category__not_in" => array( 15 ) ); query_posts( $query ); ...
2
votes
0answers
26 views

Get posts with condition on comment meta value

I have to fetch all the posts post_type=projects and post_status=publish which have the latest comment of type message older than 5 days with comment_meta value as key=value. I want to know how can ...
1
vote
1answer
29 views

Get posts with multiple meta values

I have a ACF select field which takes multiple value. Now I want to use get_posts() to get those custom posts. My arguments look like this: $party = 'test1'; $function = 'test1, test2'; $args = array(...
3
votes
2answers
50 views

How do I output a database option that is an array into a get_posts array?

This must be fairly simple, but I'm puzzled. And I may be going about it backwards. How do I output a database option that is an array into a get_posts array? I have an option in the database that ...
1
vote
1answer
35 views

Return Taxonomy/Term Information with Posts (WP_Query/get_posts)

Is it possible to return taxonomy/term information for posts along with the posts themselves when querying with get_posts? I have around 150 items I am querying so I don't want to loop and pull each ...
0
votes
0answers
21 views

Display Posts in Admin Page

I create a admin page. Now I need to display posts in that page. Should I use WP_Query or get_posts()? (Pagination should be there) Note : I have read When should you use WP_Query vs query_posts() ...
0
votes
0answers
51 views

get_posts by category_name does return all posts

When I query (using get_posts) by category_name (string) I get all posts returned of any category. However when I select by category (int) I get the proper results. What could be wrong ? [edit] /...
0
votes
2answers
57 views

Certain number of posts with certain excerpt length

Could use some help... using this code to call up a custom number of posts from a certain categorey and only want to display the first 15 characters. However, it is showing the same excerpt on each ...
0
votes
1answer
49 views

Orderby taxonomy term id using get_posts not working

I'm looping through a series of custom post types and then grouping those by a taxonomy term. That is working great, however I have not been able to order these groupings by term_id. I used a ...
1
vote
0answers
29 views

Get attachments for posts that belongs to a specific category

I am trying to get images which are used by a post belonging to the specific category. For example if I have plants, mushrooms and animals as post categories, I only need to retrieve images that are ...
1
vote
1answer
40 views

Filter the content from a post globally immediately after is fetched from the database

I am encrypting the content of a specific custom post type whenever i am updating or creating it. That is working fine. Is there a way to globally decrypt the content for all WordPress read ...
0
votes
0answers
28 views

I want to add values ​of a function in all posts in a particular category

I want to add values ​​of a function in all posts in a particular category, I get exactly what I want, but not the old problem appears in post_content(edit mode em dashboard) add_filter('the_content',...
0
votes
1answer
36 views

Conditional Tag for has post [closed]

I am quite new to all the programming, and I am now stuck with the following. I installed the plug-in If Menu which lets you show specific menu items when Conditional statements are true or false. I ...
0
votes
1answer
26 views

Remove Featured Images from Posts Older Than a Certain Date

I run a network of sites, with hundreds of editors, and lately we've had image copyright trolls coming after us. Most of these images are a year old or older, so we're looking to remove all images ...
0
votes
0answers
88 views

WP_Query meta query not returning results as expected

I'm trying to run a get_posts query to determine if a users ID is either set as a meta key value or is included within the array of another meta key for an event on a given date. I am passing $status,...
0
votes
2answers
33 views

get posts that doesn't contain a specific tag

I want to get all the posts that do not contain the tag 'index'. How can it be done? I mean in the reverse of get_posts(array('tag' => 'index')) Thank you
0
votes
1answer
31 views

wp json api - get posts by category

I have added a method to core controller of WP JSON API plugin that extracts the posts by category wise, however getting only one category data. Please find the code below. public function ...
0
votes
1answer
47 views

Group by custom field value (start and end times)

I have the following loop that is outputting a schedule for a conference. At the moment it's looping through a custom post type, grabbing the info, then outputting it in a block. So essentially each ...
0
votes
1answer
33 views

Get_posts not returning any posts when used with switch_to_blog

I'm attempting to pull in some order information from the "shop_order" post_type. This is on a multisite network, so I'm using switch_to_blog(1). When I set the post type as "post" it works great and ...
1
vote
1answer
26 views

get_posts that match a user-specified value on a page

On each page, I want the admin to choose which case history post summaries will be displayed depending on the post category. My code below works but it is very clunky if you have lots of categories. ...
0
votes
1answer
37 views

Create a hierarchical loop at predefined markup requirements

I try to achive this in wordpress based on my theme: fullpage.js demo So I have a predefined markup for vertical sections (parents) and one for horizontal slides (children). Parents only contain ...
0
votes
1answer
34 views

meta query not retrieving posts

I am attempting to use get_posts() to retrieve posts that have certain topics attached to them, in my custom post type named 'leaders' Here is my query. $args = array( 'post-type' => 'leaders'...
0
votes
2answers
60 views

Check return value of get_posts

I've been trying to change my WP_Query to get_posts methods. But I am not really sure how to check if get_posts is null or have a value. How can i transform this WP_Query checker to appropriate ...
0
votes
1answer
160 views

Get posts by language in Polylang plugin

I use the Polylang plugin to translate my website in Italian and German. How can I get the latest post in Italian? I'm using the arguments below to get the content of the post, which afterwards I ...
0
votes
1answer
11 views

Find owner of coupon

I'm attempting to run a function for a user if they have a certain coupon. I'm using the plugin Smart Coupons to generate coupons with prefixes and suffixes. I can get a list of all the coupons in ...
1
vote
1answer
70 views

Meta Query with date and time on the same Day before given time

I have a metaquery for a custom post type "events". Their start date is stored as a meta field in this format: 2016-02-05 19:00:00 These are my query args: $args = array( "posts_per_page" =>...
2
votes
1answer
95 views

How to get post content by calling ajax?

I am working on a plugin .I have a custom post type team.Custom post has four posts of different categories.I used this code to send post id of each using ajax. $(document).ready(function () { ...
1
vote
1answer
40 views

Meta Query returns wrong number of posts

I am using this meta query inside a category: $args = array( "posts_per_page" => 12, "post_type" => array( "event", "post" ), "post_status" => "publish", "...
0
votes
1answer
72 views

Query get_posts by level depth

I have a page structure like this: -- Asia ---- China ------ Shang Hai ---- Hong Kong -- Africa -- America ---- USA ---- Canada I want to use get_posts to get all posts that I marked in bold (...
0
votes
0answers
33 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', '...
1
vote
1answer
30 views

Get posts by name and taxonomy term

How do I get all posts that has a taxonomy term and a specific name/slug? I have tried with the following arguments but without getting the wanted result. What am I missing, how can I combine the ...
0
votes
0answers
16 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
31 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 ...
7
votes
1answer
135 views

Alternative to get_posts() due to multithreading cache crash

I am using pthreads to creat multiple threads. Each of those threads at one point tries to use get_posts() as follows: $args = array( 'post_type' => 'post', 'post_status' => 'any' ); $...
1
vote
1answer
37 views

WordPress takes too long to show 404 error on images (on LEMP stack)

I have installed WordPress on LEMP stack on DigitalOcean and noticed that all the 404 images on the pages are taking too long to show a 404 error message. Those images are not existing so it will ...
0
votes
0answers
33 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
1answer
64 views

offset and max_num_pages in pagination gallery

I rewrote the code galleries and stopped at the pagination. How can I get the maximum number of pages? at the moment I can not define it, and put a test for the number 5. (Here "for ($ i = 1; $ i &...
0
votes
3answers
48 views

How can I use wordpress functionality outside of WP framework

I require to retrieve a list of the recently created blog posts or any Query-based usage of WP posts inside my PHP website and not within WP framework. I am new to Wordpress and stucked here. I ...
0
votes
2answers
40 views

Custom Post type Query post is not working

I created a custom post type tickets, than I added few tickets in it. But with the following code, I tried to show list of tickets submitted by the current user and its not working for me. global $...