Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [get-posts]

get_posts() is a function for creating multiple loops. It retrieves a list of latest posts or posts matching criteria.

0
votes
0answers
8 views

List attachments by taxonomy

Trying to list two columns of attachments (pdfs), each with taxonomies (tags) of either "sub" or "ins". I almost have it but no quite: <?php $terms_array = array( 'taxonomy' => '...
0
votes
2answers
32 views

Query a custom taxonomy in a function to create an csv file

I a problem with getting the query for custom taxonomy to work in this function. The $filter is filled with data but the get_posts() does not use it? The query works without the tax_query and there ...
0
votes
1answer
25 views

In a multisite, how can I get posts from one site and display their permalinks in another site?

I have a WordPress multisite with one main site and four sub-sites. In a PHP template on my main site, I would like to get the posts from one of the sub-sites and print the permalinks to the page. ...
0
votes
0answers
13 views

Get posts argument meta query

I'm trying to get some Custom Post Type data thanks to get_posts. I need to get the CTP where the date (added by an ACF input) is before a date. I have this : $posts = get_posts(array( '...
0
votes
1answer
30 views

How to add post page pagination to template part?

How can I get this page to display the post page pagination? I'm using a custom blog template with a get_template_part. https://www.nowitconnects.com/blog/ <?php /** * Template part for ...
0
votes
1answer
22 views

get_posts() not working when accessing with a custom user role

I've stumbled across something that I can't seem to find any documentation on regarding WP 'get_posts' function. I've got a web application that has multiple custom post-types and multiple custom ...
0
votes
2answers
43 views

Get all posts which was posted on X Days WordPress

I want to get all post which was posted on X Days, I don't want 7 days old post or 1 Month old posts, Because it will return all posts which will be older 7 days or one month. Like Today is 15 SEP, I ...
0
votes
1answer
23 views

custom hierarchical taxonomy and custom post type list contains surplus posts

I wish to list custom taxonomy terms as titles and custom posts as lists under titles: Basics List item1 List item2 Movies List item3 Images List item4 However, custom taxonomy is HIERARCHICAL ...
0
votes
1answer
29 views

get_posts custom field

This is a silly question, but I can't find the proper way to ask it to google. so, sorry if this is a repetitive question. I give a custom field with a checked that the user can check if he want ...
1
vote
0answers
28 views

Query Multiple Custom Posts by Custom Fields

We have 3 custom post types and we need to query all 3 and join them in order the get that data to build up a complete list of films at a venue. Tables are as follows, with there unique ID's. The ...
0
votes
1answer
29 views

Using get_posts to get posts based on a checkbox value with Advanced Custom Fields

I have a custom post type, "Jobs". These jobs have an ACF checkbox field, "city". "Jobs" can have more than one "city," so the jobs returned have meta values look something like this: [city] => ...
0
votes
0answers
23 views

Filtering custom posts by custom taxonomy and user role using get_posts

I'm trying to filter my custom posts in a get_posts loop by first checking if the current user has a particular role and then filtering by a custom taxonomy term. However, I can't seem to get the ...
0
votes
0answers
79 views

Gravity Form After Submission Update Custom Post Type Taxonomy Terms

I am creating an online proposal system using a custom post type called 'proposal'. For the approval form, I am simply using a Gravity Form which then emails me if the client approves the proposal. ...
1
vote
1answer
34 views

Are there sub-systems in WordPress that would employ data structures beyond CPT that a `get_posts` won't be able to catch?

I'm building functionality to remove posts that have a certain key/value term pair. All fine and dandy, I can run a query like this: $posts = get_posts([ 'post_type' => 'any', '...
0
votes
0answers
9 views

How to get post data of Quiz Cat Plugin

I want to get quiz data of "Quiz Cat" plugin, I tried researching in the documentation about the code in plugin. But did not get anything regarding it. I know how to get post data of blog posts as ...
0
votes
1answer
78 views

get_posts - get all posts by array of author

I have a case like below. Confused how to use the wpQuery to achieve this This is for a single user. Not sure how can i pass the array. global $current_user; get_currentuserinfo(); ...
1
vote
2answers
224 views

How to get post from all Blog Multisite to the Main Site?

How do I display all posts from multisite to the main site? Please help me. thanks.
1
vote
1answer
79 views

How to filter get_post with ACF by a checkbox field?

So, I have a custom content type called "team" where I have an ACF field attached called "external" which is a checkbox. I am currently getting all the posts by passing the following arguments array ...
0
votes
1answer
121 views

Quickest way to get last or oldest post date - WP Query

I know how to get the last or oldest post data using following code $posts = get_posts(array( 'post_type' => 'post', 'order_by' => 'publish_date', 'order' => 'ASC' )); And then I will ...
2
votes
1answer
43 views

How to get previous 10 days post from a specific date - WP Query

I want to know how to get previous 10 days post from a specific date, as I know that it can be done from current date as below $args = array( 'post_type' => 'post', 'date_query' => ...
0
votes
2answers
171 views

get the_content by ID and save the result to one array

I try this: <?php function get_ct($id){ $ct = apply_filters('the_content', get_post_field('post_content', $id)); return $ct; } $arr = array('post_content' => get_ct(...
0
votes
0answers
76 views

List all custom taxonomy terms related to another taxonomy

I want to list all custom taxonomy terms related to another taxonomy. For example the following case: Custom Post Type: Car Taxonomy 1: Brand ->Terms: Audi, Bentley, BMW, Bugatti, ... Taxonomy 2: ...
0
votes
1answer
33 views

Portfolio list view after clicking back button

how would it be possible to get back to the same portfolio listing page, after the clicking browser back button from single portfolio item? Now it goes back to the first page of portfolio listing. ...
0
votes
0answers
235 views

REST API Working for GET but not for POST?

I am trying to create a post through the REST API. I am able to access the API by getting the existing posts, as per the screenshot below: However, when I try to do a similar request to create a new ...
4
votes
1answer
51 views

Is the first item returned by get_posts() always the latest post?

I want to retrieve the modification date of the latest post. To do this, first I get the latest post: $latest_post = get_posts()[0]; Can I be certain that the returned object is always the latest ...
1
vote
1answer
13 views

Simple Filter between multiple taxonomys

I create 2 dropdowns one for each category & tag and filtering posts successfully. After that i create a custom taxonomy cat and try to filter post between all three dropdowns. But dropdown for ...
0
votes
1answer
11 views

How to apply a function to a metadata value before launch a WP Query?

I have these WP_Query arguments: $args = array( 'post_type' => 'my_post_type', 'order' => 'ASC', 'meta_key' => 'date', 'orderby' => 'meta_value_num' ); ...
0
votes
0answers
49 views

how to display active, upcoming and past event with featured listing with pagination

I have a code that work fine for Active Events Page, Upcoming Event Page & Past Event Page with a event_start_date later than today. What I want is? A : To show Active, Upcoming, Past event post ...
0
votes
1answer
60 views

Fill the exclude array() in get_posts()

I'm using this code to populate the dropdown menu in a meta box. $parents = get_posts( array( 'post_type' => 'jhk_story', 'orderby' => 'ID', ...
0
votes
0answers
19 views

Posts page listing pages as well

I have set my Posts to output on a specific page by selecting that page as the posts page in the settings->reading tab. That page is outputting content using my index.php template like I wanted. ...
0
votes
2answers
99 views

Query post with meta value in set of values

I am trying to build a query that returns all posts, with a meta value that exists in a set of values. My posts have a meta key called Asin_unique and I want to find all posts, that have the value ...
0
votes
0answers
34 views

Using the_content() causes the white screen of death

I have a custom post type for creating popups. I have a loop where I display all the popups and it all works fine, until I try get the content using the_content(); the_title(), the_ID() etc., all ...
0
votes
0answers
45 views

Order posts by specific post IDs

I have the following code: $viewed_products = [3358, 3296, 3929, 3368]; $query_args = array( 'posts_per_page' => 4, 'no_found_rows' => 1, 'post_status' => 'publish', '...
2
votes
1answer
78 views

How to retrieve a value from get_posts()? [closed]

I'm just trying to retrieve a value of 'title_name' from get_posts and gets the error "cannot use object of type WP_post as array..." The reason I'm not using have_posts/the_posts is because I want to ...
1
vote
1answer
398 views

Get posts by meta value with date

I have a post type called "agenda" and one of its meta value is the date of the event. How can I get the posts of the current year based on the meta value? I tried this args above but it doesn't ...
2
votes
1answer
65 views

get_posts gives different result than wpdb->get_results

I ran into something that has me completely stumped. For a cron job I need to retrieve which users are 'marked' as VIP and then retrieve the posts from these VIP users. global $wpdb; $...
2
votes
0answers
53 views

Adding multiple post queries with parent and children to page - Best Way

So I am interested in allowing a custom menu to show "in three places: Menu area, Homepage body, and footer" based on the posttype "page" table list or parent and children entries and not using the WP ...
0
votes
2answers
38 views

Custom Category widget

I have a custom code in sidebar.php that shows all my categories and number of posts+custom posts. The code is working fine but, since I copied/pasted and modified various other codes from ...
0
votes
1answer
115 views

Posts query according to meta box date

I'm struggling to get a working solution with wp_query for Event management, Currently post order by event start date & time work well. Now I want some custom settings. Have two meta boxes ...
0
votes
1answer
132 views

How to get only one category of custom post type?

I get all post successfully of CPT which are Order by meta_key value Date. Code is below $today = date("Y/m/j"); query_posts(array( 'post_type' => 'event', 'posts_per_page' => 10, 'meta_key' =&...
-1
votes
1answer
35 views

wordpress show category link instead of post link [closed]

I'm running WordPress on localhost using XAMPP. I have a few posts and added them to a specific category (for example cat1 and cat2). I've added the categories to the menu, and when I click on the ...
1
vote
2answers
45 views

show first 3 thumbnails of posts in different sizes [closed]

i want to make a little Header with the 3 recent thumbnails in different sizes and start my loop with the 4th recent posts, can someone give me a function for that please? please no widgets i want to ...
-1
votes
1answer
123 views

orderby and order filter in get_posts or WP_query function in wordpress not working

I have function in wordpress plugin which queries the posts using get_posts($array). But I wanted this to orderby post_modified field of the posts table in DESCENDING order, for which I have this code ...
0
votes
1answer
762 views

How to get image from url from the database?

Hello everyone I need to fetch rows and display them. This is not a aproblem, but! I have column icon, which contains the url of the icon, so I should display the image from the url. Could you tell me ...
0
votes
0answers
25 views

week days sorting based on starting day

I have a taxonomy with weekdays. I want them sorted based on basis of starting day opted by the user. Basically, I am working on Timetable and different regions have different starting day of week. ...
1
vote
1answer
18 views

Ho to add get_relative_date and post_except to this get_latest_post query?

tried different ways to implement without any success, Any help? <?php $recent_posts = wp_get_recent_posts(array( 'numberposts' => 99, // Number of recent posts thumbnails to display '...
0
votes
1answer
24 views

Query posts based on user preferences

I have 'category_preferences' saved in each user_meta which is an array of term IDs of a custom taxonomy. The custom taxonomy has ~100 items. As an example of the meta field value, where 14 and 15 are ...
0
votes
1answer
51 views

Wordpress query reverse order

$args = array('post_type' => 'etlap', 'posts_per_page' => 5, 'post__in' => $ids, 'post_status' => 'any', 'orderby' => 'post__in'); I want to make the orderby status reversed. How is it ...
0
votes
1answer
63 views

allow user to edit posts made by others users based on the user role

I group users by custom user roles so each user groups can view and edit each others CPT . the problem i face now is when i give the user role capabilities related to edit and delete others posts, the ...
0
votes
1answer
32 views

get_posts - check if custom field has content?

I have this loop that works fine but I have to check if the custom fields of the post objects ("houses") have content. I try this with "isset" and nothing happens. Tried "isset", too but same problem. ...