WordPress and buddypress programming

Private Notes admin content only

Viewing 0 reply threads
  • Author
    Posts
    • #2283
      michael mc
      Keymaster
      @michael

      When working on posts and pages, drop yourself a private note that only you (and other admins) can see. All you need is the following code in your theme’s functions.php file:

      PHP
      function private_notes($atts, $content = null) {
      	if (current_user_can('publish_posts')) {
      		return '<div class="private-note">' . $content . '</div>';
      	}
      	return '';
      }
      add_shortcode('note', 'private_notes');

      This function sets up a shortcode that you can use in any post or page. Here is an example of how it works:

      When displayed, private notes will be wrapped with the following markup:

      <div class="private-note">This is a private note.</div>

      Notice the included private-note class, making easier to style. As with most everything else, this method is highly customizable. Explore the code, the Codex, and get jiggy with it.

Viewing 0 reply threads
  • You must be logged in to reply to this topic.