Problem:
We are using toolset_get_related_post and would like to specify the post status of the posts this function should return us.
How can we do this?
Solution:
toolset_get_related_post will Retrieve an ID of a single related post.
That posts post_status can be defined in the function, so if you want a specific status, you would have to specify it.
You should pass an array of post status values or a string with one or more statuses separated by commas.
The passed statuses need to be among the values returned by get_post_statuses() or added by the toolset_accepted_post_statuses_for_api filter.
Example:
$role_name_to_return = '';//parent or child $args = array();// see args array - Additional query arguments. $post_status = 'publish,draft';//you can only use those from https://developer.wordpress.org/reference/functions/get_post_statuses/ or passed to toolset_accepted_post_statuses_for_api $writer = toolset_get_related_post( $post_id, array( 'one-side', 'other-side' ), $role_name_to_return, $args, $post_status );
Relevant Documentation:
https://developer.wordpress.org/reference/functions/get_post_statuses/
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | - | 14:00 – 20:00 | 14:00 – 20:00 | 14:00 – 20:00 | 14:00 – 20:00 | 14:00 – 20:00 |
- | - | - | - | - | - | - |
Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)
Dieses Thema enthält 5 Antworten, hat 3 Stimmen.
Zuletzt aktualisiert von vor 4 Jahren, 10 Monaten.
Assistiert von: Beda.