- How to Begin Writing Your First WordPress plugin
- Structuring Your First WordPress Plugin
- Writing Your First WordPress Plugin Part 3
- Writing Your First WordPress Plugin Part 4
- Writing Your First WordPress Plugin Part 5
- Writing Your First WordPress Plugin Part 6
- Writing Your First WordPress Plugin Part 7 – Final
In part 5 of Writing Your First WordPress Plugin, I’m going to take you through the process of adding an admin options page to your first WordPress plugin. This options page will allow your user to configure the settings for the plugin very easily. In this case, we’re going to use it to allow the user to enter their Twitter url, which is displayed at the bottom of each post. The options page will allow more than that, but we will start simple.
You must be logged in to view the rest of this content. Register or login from the sidebar.
The end result of these two functions should look like this:
Do NOT forget to include your new “admin-page.php” file into the main plugin file, just as we have the others.
In the next part of this series, we’re going to get a little more advanced and I’m going to show you how to create the option fields themselves. Once that is done, we’ll be able to add a lot more flexibility to our plugin.
Download WIP Plugin

Thank you for continuing this series. I was waiting for it.
You’re welcome! Part 6 is scheduled for tomorrow
Not sure I understand the purpose of the output buffer. Removing ob_start() and echo ob_get_clean() returns the same result on the admin page. What are the advantages of using this function?
Thanks for this useful series.
The advantage is when you need to return the entire content of the page (or store it in a variable), rather than just echo it.
hi, why you don’t use ?> end of all php files?
Because it is not needed. Since it’s not needed, there’s really no reason to include it.
Pippin can you help me little bit in writting a plugin.i want to write a sign up plugin
Please elaborate on the plugin you want to make.
I want this…………..
When a user signs up for a volunteer opportunity,the following happens:
1. An email is sent to the volunteer with thanks.
2. Th email address is checked against user list.If there is no user with that email address,a new user is created.
3. The user is subscribed to receive updates on the project with a new comment is posted.
Are you looking for suggestions on how to write the plugin, or for me to do it for you?
Hi Pippin, I really enjoy your great tutorial. I have a question which is do we always have to use “ob_start();” for this method ? Since I think without “ob_start();” the code will work also.
No, it is not required (except for some scenarios).
admin_menu
Hi! Thank you very much for your tutorial!
Can you please explain how can i display plugins settings in “Edit Post” window. Like it done in SEO Ultimate plugin
It is like a widget in “Edit Post” window.
That is a whole series of tutorials in and of itself. Take a look at this project: https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress It provides a pretty simple way to add meta boxes.
Hi Pippin,
I have been working through lesson 5 and get the following error:
The plugin generated 407 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.
This is my code:
My first WordPress options
why not working????
<php
echo ob_get_clean();
}
function mfwp_add_options_link(){
add_options_page('My first WordPress function', 'My first plugin', 'manage_options', 'mfwp-options', 'mfwp_options_page');
}
add_action('admin_menu', 'mfwp_add_options_link');
I have included it in the Index file. No other plugins are active.
Any ideas?
Thanks
As it turns out the HTML worked in the comment so I have re-added with some full stops so you can see the full code.
My first WordPress options
why not working????
<php
echo ob_get_clean();
}
function mfwp_add_options_link(){
add_options_page('My first WordPress function', 'Peters plugin', 'manage_options', 'mfwp-options', 'admin-page.php');
}
add_action('admin_menu', 'mfwp_add_options_link');
That’s not the complete code. Can you paste the entire plugin into snippi.com and share the link?
Hi pippin, link is:
http://snippi.com/s/94tw3d0✖
Cheers
Hello All, I have worked out the issue and it was so minor I can not believe I missed it.
The problem was I had <php, NOT <?php.
This seems to have caused the code to become output instead of identifing up coming code.
It now works…
Thanks
Great!