diff --git a/ast-template-view.php b/ast-template-view.php index 5033e9f..7248317 100644 --- a/ast-template-view.php +++ b/ast-template-view.php @@ -20,15 +20,17 @@ * Register custom post meta key. */ function ast_register_post_meta() { - register_post_meta( - 'page', - PAGE_TEMPLATE_META_KEY, - array( - 'show_in_rest' => true, - 'single' => true, - 'type' => 'boolean', - ) - ); + foreach ( array( 'page', 'post' ) as $post_type ) { + register_post_meta( + $post_type, + PAGE_TEMPLATE_META_KEY, + array( + 'show_in_rest' => true, + 'single' => true, + 'type' => 'boolean', + ) + ); + } } /** @@ -72,7 +74,7 @@ function ast_query_vars( $query_vars ) { function ast_views_edit_page( $views ) { global $wpdb; // phpcs:ignore WordPress.Security.NonceVerification.Recommended - $post_type = $_GET['post_type']; + $post_type = $_GET['post_type'] ?? 'post'; $ast_view_args = array( 'post_type' => $post_type, @@ -88,8 +90,10 @@ function ast_views_edit_page( $views ) { JOIN $wpdb->postmeta AS pmeta ON posts.ID = pmeta.post_id WHERE post_status = 'draft' + AND posts.post_type = %s AND pmeta.meta_key = %s AND pmeta.meta_value = 1", + $post_type, PAGE_TEMPLATE_META_KEY ) ); @@ -119,6 +123,7 @@ function ast_views_edit_page( $views ) { } add_filter( 'views_edit-page', 'ast_views_edit_page' ); +add_filter( 'views_edit-post', 'ast_views_edit_page' ); /**