Покопавшись в плагине, они подключились к фильтру the_posts с помощью следующей функции:
Код: Выделить всё
public function display_scheduled_events( $posts ) {
global $wp_query, $wpdb;
if ( is_single() && $wp_query->post_count == 0 && isset( $wp_query->query_vars['sp_event'] ) ) {
$posts = $wpdb->get_results( $wp_query->request );
}
return $posts;
}
Код: Выделить всё
Array
(
[0] => WP_Post Object
(
[ID] => 53851
[post_author] => 367
[post_date] => 2023-08-09 19:00:00
[post_date_gmt] => 2023-08-09 18:00:00
[post_content] =>
[post_title] => My post title
[post_excerpt] =>
[post_status] => publish
[comment_status] => closed
[ping_status] => closed
[post_password] =>
[post_name] => 53851
[to_ping] =>
[pinged] =>
[post_modified] => 2023-08-15 21:08:18
[post_modified_gmt] => 2023-08-15 20:08:18
[post_content_filtered] =>
[post_parent] => 0
[guid] => https://my-website.co.uk/?post_type=sp_event&p=53851
[menu_order] => 0
[post_type] => sp_event
[post_mime_type] =>
[comment_count] => 0
[filter] => raw
)
)
Код: Выделить всё
Array
(
[0] => stdClass Object
(
[ID] => 53851
)
)
Подробнее здесь: https://stackoverflow.com/questions/783 ... he-post-id
Мобильная версия