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
47 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
2answers
517 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 ...
0
votes
0answers
9 views

Class For Dependent Child Post Data using get_posts()

I want to use a class to display various parts of a dependent post via a class. This is my first stab into OOP, so please be try to be somewhat gentle, if possible. :) At a high-level I have a two ...
1
vote
2answers
37 views

Query random post from different categories

I have six regular categories, not custom (each category having between 5 and 10 posts) and I am trying to display one random post from each category on the page. The problem with the output is ...
0
votes
2answers
4k views

Custom Taxonomy with tax_query

So I've created a custom taxonomy type with a plugin (CMS Press) and now I'm trying to get all of the posts with the taxonomy terms in that taxonomy. My get_posts looks like this: $args = Array( ...
0
votes
3answers
2k views

Get id of category from drop down menu

Im trying to get the category ID from wp_dropdown_categories();and then pass the ID into a loop to have it output posts titles from that particular category. I currently have this: <form ...
0
votes
1answer
3k 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 ...
2
votes
1answer
903 views

Get Recent Posts by Date in Multisite

Everything in explanation is about CDTuts I've created a WordPress Network and I want is to get the recent posts from all of the selected subdomain blogs. I need to get the latest All organized by ...
0
votes
0answers
34 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
46 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
2answers
3k views

Pagination with get_posts seems to work but links not showing

I've a custom page template where I want to query 2 posts from a post type and 1 post from another post type. I have it set up like this: $paged = get_query_var('paged') ? get_query_var('paged') : 1; ...
0
votes
1answer
19 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
54 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
29 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
1answer
469 views

Can't pull posts of a Custom Post Type based on the custom taxonomy of the CPT

My question is about retrieving custom post types via get_posts, when custom post types also have a custom taxonomy. I can use get_posts to retrieve all posts of a custom post type, but when I attempt ...
0
votes
0answers
21 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 ...
2
votes
2answers
6k views

Use of caller_ get_ posts

For what purpose following parameter is used caller_get_posts
0
votes
1answer
30 views

Wordpress get all post with like in terms [duplicate]

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 ...
-2
votes
1answer
74 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
2answers
20 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 ...
6
votes
3answers
3k views

Getting the Intersection of Two Custom Taxonomy Terms for a Custom Post Type?

(Moderators note: Was originally titled "How to get_posts of a custom post type that is in two custom taxonomies?") I have a custom post type that has two taxonomies which are separate, one called "...
0
votes
0answers
57 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 ...
0
votes
1answer
55 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
29 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
36 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
38 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
24 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
5answers
608 views

Why always one post missing

In my custom query, every time I query for posts from a particular category using WP_Query() and the category has 10 posts for example, I seem to be missing a post. So querying for 10 posts only ...
0
votes
0answers
63 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] /...
1
vote
2answers
1k views

get_posts not working as expected

I'm trying to get posts from 3 different categories and list them on the front page: // Carousel articles $args = array( 'numberposts' => 3, 'orderby' => 'date', 'category' => 'karusell'...
3
votes
2answers
2k views

latest 5 posts using switch_to_blog loop

im sure i must be doing something wrong and would really appreciate a little help. I am trying to loop through all of my Sub Dir "Multisite" blogs using switch_to_blog, below: global $wpdb, $blog_id,...
4
votes
2answers
16k views

Get posts under custom taxonomy

I am not getting the posts under custom taxonomy(fabric_building_types).I am getting cat_id and cat->name also but not able to get the posts. $args = array( 'type' => 'post'...
0
votes
2answers
63 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
63 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
31 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
43 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
28 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 ...
2
votes
3answers
8k 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
113 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
36 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
0answers
199 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 ...
1
vote
2answers
2k views

get_posts and multiple categories

I have created a custom query in hopes of showing the top posts from some child categories. The query has a big flaw: some posts belong to two categories; but, even if they get marked in BOTH ...
0
votes
1answer
48 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
4answers
2k 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
37 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. ...