Skip to content
Home » Blog » Digital Marketing » Wordpress » How I Created a Custom Header Footer WordPress Plugin

How I Created a Custom Header Footer WordPress Plugin

  • by
A woman working on a laptop, customizing a WordPress plugin interface with code and UI elements on the screen, in a cozy home office with a warm sunset view.

As a digital marketer and blogger, I focus on content creation and SEO rather than coding. However, I recently needed a Custom Header Footer WordPress Plugin for my site. Instead of searching for plugins, I thought, why not create my own? The problem was—I had no coding experience.

Luckily, with expert (ChatGPT) guidance, I got a fully functional Custom Header Footer Plugin built for my site. In this blog, I’ll share my experience and a step-by-step guide on how you can do the same—even if you’re not a developer! Before implementing this process backup your files. If you face any problem ask ChatGPT for better solution.

Why Create a Custom Header & Footer Plugin?

While many WordPress themes and plugins allow customization, they often have limitations. A dedicated plugin gives you more control, allowing you to:

  • Add custom scripts (like Google Analytics, Facebook Pixel, or Chatbots) without editing theme files.
  • Easily update header and footer content from the WordPress dashboard.
  • Keep customizations intact even when changing themes.

The Process: How I Got My Plugin Developed

Since I’m not a coder, I sought expert (ChatGPT) help to get the plugin built. Here’s the process that worked for me:

1. Defining the Requirements

I wanted a simple plugin with the following features:

  • A settings page in the WordPress admin panel.
  • Fields to input custom header and footer content.
  • Automatic placement of content in the <head> and before </body>.

2. Getting the Plugin Developed

Instead of manually coding, I explained my requirements and got this fully functional plugin written for me:

Folder & File Structure

The plugin consists of a single PHP file inside a folder:

/wp-content/plugins/custom-header-footer/
 ├── custom-header-footer.php

Plugin Code The complete PHP code for the plugin:

<?php
/**
 * Plugin Name: Custom Header Footer
 * Plugin URI: https://blogofanup.com
 * Description: A simple plugin to add a custom header and footer to your WordPress site.
 * Version: 1.0
 * Author: Anup Ain
 * Author URI: https://blogofanup.com
 * License: GPL2
 */

// Prevent direct access
if (!defined('ABSPATH')) {
    exit;
}

// Add settings menu
function chf_add_admin_menu() {
    add_menu_page('Header Footer Settings', 'Header Footer', 'manage_options', 'chf-settings', 'chf_settings_page');
}
add_action('admin_menu', 'chf_add_admin_menu');

// Register settings
function chf_register_settings() {
    register_setting('chf_settings_group', 'chf_header_content');
    register_setting('chf_settings_group', 'chf_footer_content');
}
add_action('admin_init', 'chf_register_settings');

// Settings page
function chf_settings_page() {
    ?>
    <div class="wrap">
        <h1>Custom Header & Footer Settings</h1>
        <form method="post" action="options.php">
            <?php settings_fields('chf_settings_group'); ?>
            <?php do_settings_sections('chf_settings_group'); ?>
            <table class="form-table">
                <tr valign="top">
                    <th scope="row">Header Content</th>
                    <td><textarea name="chf_header_content" rows="5" cols="50"><?php echo esc_textarea(get_option('chf_header_content')); ?></textarea></td>
                </tr>
                <tr valign="top">
                    <th scope="row">Footer Content</th>
                    <td><textarea name="chf_footer_content" rows="5" cols="50"><?php echo esc_textarea(get_option('chf_footer_content')); ?></textarea></td>
                </tr>
            </table>
            <?php submit_button(); ?>
        </form>
    </div>
    <?php
}

// Output header content
function chf_add_custom_header() {
    echo get_option('chf_header_content');
}
add_action('wp_head', 'chf_add_custom_header');

// Output footer content
function chf_add_custom_footer() {
    echo get_option('chf_footer_content');
}
add_action('wp_footer', 'chf_add_custom_footer');

3. Installing & Activating the Plugin

Once the plugin was ready, I installed it on my WordPress site:

  1. Create a folder: custom-header-footer inside wp-content/plugins/.
  2. Save the PHP file: custom-header-footer.php inside this folder.
  3. Go to WordPress DashboardPlugins → Activate “Custom Header Footer”.

4. Using the Plugin

After activation, a new settings page appeared under Settings → Header Footer. Here, I could:

  • Add HTML, scripts, or text for the header.
  • Add custom scripts or content before </body>.
  • Save changes, and the content automatically applied to my site.

The Best Part? No Theme Editing Needed!

Previously, I would have had to manually edit my theme’s header.php and footer.php. Now, with this plugin: ✅ My custom scripts remain even if I change themes.
✅ I can update the header & footer without touching code.
✅ My site stays secure without modifying core files.

Conclusion

I didn’t write a single line of code, yet I successfully got a custom plugin built for my WordPress site. This experience taught me that even without coding expertise, you can create custom solutions by defining requirements and seeking the right help.

If you ever need to customize your WordPress site’s header and footer, try building (or getting built) a plugin like this instead of modifying theme files.

💬 Have you ever wanted to create your own WordPress plugin? Share your experience in the comments below!

👉 Want to optimize your website further? Check out my detailed guide on Digital Marketing Strategy!

Create a Powerful Custom Header & Footer for WordPress

Transform your website’s appearance and functionality with a customized header and footer.

What is the biggest benefit of a custom header & footer?
Improved Branding & Navigation
Which tool is best for customizing headers & footers in WordPress?
Elementor
What can a custom header contain?
Logo, Menu, CTA Buttons
How does a custom footer improve engagement?
Adding Useful Links & CTA
What is an important element of a footer?
Contact Information
Why is mobile responsiveness important for headers & footers?
Ensures Good User Experience on All Devices
Author Profile

Anup Ain

Hey, my name is Anup Ain. I am a blogger and a digital marketing intern. I enjoy sharing my knowledge and experiences with others.