InMotion Hosting Support Center

The Extra Post Info WordPress plugin was a plugin developed for my create your first WordPress plugin tutorial.

This basic WordPress plugin simply allows users to add some extra info to all their posts, but serves to teach how a WordPress plugin should be built. It was a lot of fun to create, and I hope to continue to add to it.

extra post info admin page read setting from database

I tried to keep the tutorial information packed, while still approaching WordPress plugin development from a step by step format. If you were just looking to grab the full WordPress plugin script that's what this page is for.

Completed Extra Post Info WordPress plugin

Here is my plugin in all its glory, this version is heavily commented, so hopefully you can easily tell what's going on.

You can also grab the raw text version as well. Follow the steps from the create WordPress plugin script guide if you are unsure what to do with this full plugin script. You would just want to save this script to the file:


Plugin name: WordPress Extra Post Info
Plugin URI:
Description: A simple plugin to add extra info to posts.
Author: Jacob Nicholson
Author URI:
Version: 0.5

// Call extra_post_info_menu function to load plugin menu in dashboard
add_action( 'admin_menu', 'extra_post_info_menu' );

// Create WordPress admin menu
if( !function_exists("extra_post_info_menu") )
function extra_post_info_menu(){

  $page_title = 'WordPress Extra Post Info';
  $menu_title = 'Extra Post Info';
  $capability = 'manage_options';
  $menu_slug  = 'extra-post-info';
  $function   = 'extra_post_info_page';
  $icon_url   = 'dashicons-media-code';
  $position   = 4;

  add_menu_page( $page_title,
                 $position );

  // Call update_extra_post_info function to update database
  add_action( 'admin_init', 'update_extra_post_info' );


// Create function to register plugin settings in the database
if( !function_exists("update_extra_post_info") )
function update_extra_post_info() {
  register_setting( 'extra-post-info-settings', 'extra_post_info' );

// Create WordPress plugin page
if( !function_exists("extra_post_info_page") )
function extra_post_info_page(){
  <h1>WordPress Extra Post Info</h1>
  <form method="post" action="options.php">
    <?php settings_fields( 'extra-post-info-settings' ); ?>
    <?php do_settings_sections( 'extra-post-info-settings' ); ?>
    <table class="form-table">
      <tr valign="top">
      <th scope="row">Extra post info:</th>
      <td><input type="text" name="extra_post_info" value="<?php echo get_option('extra_post_info'); ?>"/></td>
  <?php submit_button(); ?>

// Plugin logic for adding extra info to posts
if( !function_exists("extra_post_info") )
  function extra_post_info($content)
    $extra_info = get_option('extra_post_info');
    return $content . $extra_info;

// Apply the extra_post_info function on our content  
add_filter('the_content', 'extra_post_info');

Was this article helpful?

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Support Center Login

Our Login page has moved, Click the button below to be taken to the login page.

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

0 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!