From 99593ee863d72ee9c68865b03ddc41e1e07cbcfc Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 22 Jun 2021 14:59:21 +0900 Subject: [PATCH] =?UTF-8?q?WP=20PLUGIN=E3=80=80=E6=A4=9C=E7=B4=A2=E3=81=AE?= =?UTF-8?q?=E3=82=BD=E3=83=BC=E3=83=88=E8=A8=AD=E5=AE=9A=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ・検索のソート対象にカスタム投稿を追加 --- class/class.apop.apop_ui.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/class/class.apop.apop_ui.php b/class/class.apop.apop_ui.php index 9868580..99e910c 100644 --- a/class/class.apop.apop_ui.php +++ b/class/class.apop.apop_ui.php @@ -17,9 +17,8 @@ if ( ! class_exists( 'APOP_UI' ) ) { public static function get_all_search_normal_posts( $key ) { $meta_key = '_apop_post_' . $key; - $args = self::create_search_normal_args( $meta_key ); + $args = self::create_search_normal_args( $meta_key, $key ); $posts_data = get_posts( $args ); - $list = array(); foreach ( $posts_data as $i => $post_data ) { $order = $i + 1; $no_order = self::is_sort_post_registered( $post_data->ID, $meta_key ) ? '' : ' no-order'; @@ -32,8 +31,20 @@ if ( ! class_exists( 'APOP_UI' ) ) { } } - private static function create_search_normal_args( $meta_key ): array { + private static function create_search_normal_args( $meta_key, $key = 'normal' ): array { + $post_type = array( 'post' ); + if ( $key == 'search' ) { + $add_post_type = array_values( get_post_types( array( + 'public' => true, + '_builtin' => false, + ) + ) + ); + $post_type = array_merge( $post_type, $add_post_type ); + } + return array( + 'post_type' => $post_type, 'post_status' => array( 'publish', 'draft' ), 'posts_per_page' => - 1, 'orderby' => 'meta_value_num',