बस एक शुरुआती बिंदु, जैसा कि निश्चित रूप से मुद्दे आगे के विकास के दौरान पॉपअप होंगे। उदाहरण के लिए, अभी, खोज कार्यक्षमता टूटती है क्योंकि यह एक स्ट्रिंग (पोस्ट_टाइप) की उम्मीद करता है और यह एक सरणी प्राप्त कर रहा है।
डाक स्क्रीन में एक से अधिक पोस्ट प्रकार को सूचीबद्ध करने के लिए, हम pre_get_postsक्वेरी को हुक और संशोधित करते हैं। इस परीक्षण में, पोस्ट्स, पृष्ठ और उत्पादों को पोस्ट स्क्रीन ( http://example.com/wp-admin/edit.php) में एक साथ दिखाया जाएगा ।
add_action( 'pre_get_posts', 'join_cpt_list_wspe_113808' );
function join_cpt_list_wspe_113808( $query )
{
// If not backend, bail out
if( !is_admin() )
return $query;
// Detect current page and list of CPTs to be shown in Dashboard > Posts > Edit screen
global $pagenow;
$cpts = array( 'post', 'page', 'product' );
if( 'edit.php' == $pagenow && ( get_query_var('post_type') && 'post' == get_query_var('post_type') ) )
$query->set( 'post_type', $cpts );
return $query;
}
प्रत्येक पोस्ट के साथ एक कॉलम दिखाने के लिए एक सहायक कोड पोस्ट प्रकार:
add_filter( 'manage_edit-post_columns', 'add_cpt_column_wspe_113808' );
foreach( array( 'post', 'page', 'product' ) as $cpt )
add_action( "manage_{$cpt}_posts_custom_column", 'show_cpt_column_wspe_113808', 10, 2 );
function add_cpt_column_wspe_113808( $columns )
{
$columns[ 'cpt' ] = 'Post Type';
return $columns;
}
function show_cpt_column_wspe_113808( $column_name, $post_id )
{
if ( 'cpt' != $column_name )
return;
echo get_post_type( $post_id );
}