Skip to content

Instantly share code, notes, and snippets.

@lw-na
Forked from Mte90/dashboard-activity-cpt.php
Created April 2, 2021 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lw-na/18ab8df6daa74c2aec63eeb5576a2ed4 to your computer and use it in GitHub Desktop.
Save lw-na/18ab8df6daa74c2aec63eeb5576a2ed4 to your computer and use it in GitHub Desktop.
Add your cpts to the Widget Activity of the Dashboard in WordPress
<?php
/*
Plugin Name: Dashboard Widget Activity Custom Post Type
Plugin URI:
Description:
Author: Daniele Mte90 Scasciafratte
Version: 1.0.0
Author URI: http://mte90.net
*/
//Add the support for your cpt in the Widget Activity of the Admin Dashboard
if ( is_admin() ) {
add_filter( 'dashboard_recent_posts_query_args', 'add_page_to_dashboard_activity' );
function add_page_to_dashboard_activity( $query_args ) {
if ( is_array( $query_args[ 'post_type' ] ) ) {
//Set yout post type
$query_args[ 'post_type' ][] = 'page';
} else {
$temp = array( $query_args[ 'post_type' ], 'page' );
$query_args[ 'post_type' ] = $temp;
}
return $query_args;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment