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

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

0
votes
1answer
8 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
21 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
14 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
22 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
36 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
32 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
8 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
32 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
102 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
29 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
64 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
40 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
98 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
71 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
19 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
126 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
50 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
35 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
44 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
69 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
30 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
44 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
65 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
297 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
60 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
47 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
34 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
99 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
101 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
43 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
107 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
674 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
24 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
17 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
38 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
62 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
30 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. ...
0
votes
0answers
26 views

Navigation within parent category

I have two parent category in my blog and some sub-category. I want navigation link after single post will collect posts from the parent category of the single post. Currently i am using this code: ...
0
votes
1answer
29 views

How to display post_content from database in different <p> on template page?

I am storing some long unstyled text post_content, where title is XXX. I am selecting this content: <?php global $wpdb; $findContent = $wpdb->get_var("SELECT post_content FROM wp_posts WHERE ...
0
votes
1answer
46 views

Unique Problem with the php date and get_posts

I have several date queries on an events page that outputs events posts according to the month and the year of the post. Each post has a custom date field in the form YYYY-mm-dd and a corresponding ...
1
vote
1answer
117 views

get_children() not working properly – Only on one post?

Client wants to show how many images await the reader in a post. I say: easy peazy. Now I realize: I lied. The system only uses galleries, even for single pictures. $images = get_children(array( ...
0
votes
1answer
313 views

get the post_date of ID

How can I get the post date of ID? this is my code $id = "13"; //wp_posts ID get_post_date("Y-m-d H:i:s", $id) //is there something like this in wordpress? I dont like to create a custom query if ...
0
votes
1answer
795 views

How to find out what “Blog pages show at most” is set to [duplicate]

Under Settings > Reading, there is a field called Blog pages show at most __ posts. Since all of my queries are based off of the main query, I need to find out what's stored in that field. How would ...
0
votes
1answer
446 views

Displaying POST content with HTML tags and all

The following code allows me to display the post TITLE and content fine, but the content is not displaying as I see it on POST EDITOR. Here's the webpage where the PHP is rendered: http://queridas....
0
votes
1answer
93 views

How to Group While Loop “Results” of wp_query?

I have the results from a query and they're fine, I am getting post via tags. I want to sort the result in WHILE LOOP. Here's the code $tags = wp_get_post_tags($post->ID); if ($tags) { $...