Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@timelsass
Created May 12, 2019 07:04
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 timelsass/345f810ded211fd6b3e9510bd56ebd9a to your computer and use it in GitHub Desktop.
Save timelsass/345f810ded211fd6b3e9510bd56ebd9a to your computer and use it in GitHub Desktop.
Adds the post ID's link to edit that page in the dashboard's at a glance widget.
<?php
/**
* Plugin Name: Custom At a Glance Item
* Description: Adds the post ID's link to edit that page in the dashboard's at a glance widget.
* Plugin URI: https://gist.github.com/timelsass/345f810ded211fd6b3e9510bd56ebd9a
* Author: Tim Elsass
* Author URI: tim.ph
*/
/**
* Add new link by post ID to dashboard's at a glance widget.
*
* @param int $id post ID to add link for.
*/
function custom_at_a_glance_item( $id ) {
add_filter( 'dashboard_glance_items', function( $items ) use( $id ) {
$title = get_the_title( $id );
$items[] = '<a href="post.php?post=' . $id . '&action=edit">' . $title . '</a>';
return $items;
} );
}
// Replace 1 with the post ID of the page/post you want to have a link for in widget.
custom_at_a_glance_item( 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment