WordPressのダッシュボードに表示される最近の投稿のクエリをカスタマイズするコード。 ダッシュボードに表示される最近の投稿(アクティビティ)に、カスタム投稿の投稿を含めて表示させます。
post_typeに表示させたい投稿タイプをしてください。
例 ‘post’, ‘page’,‘news’
上記の内容で、投稿、固定ページ、「news」というカスタム投稿が、最近の投稿(アクティビティ)に表示されるようになります。
functions.php
add_filter( 'dashboard_recent_posts_query_args', 'my_dashboard_recent_posts_query_args', 10, 1 );
function my_dashboard_recent_posts_query_args( $query_args ) {
$query_args['post_type'] = array( 'post', 'sample1', 'sample2' );
if ( isset( $query_args['post_status'] ) && $query_args['post_status'] === 'publish' ) {
$query_args['posts_per_page'] = 10;
}
return $query_args;
