Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
In WordPress: Creating Custom Widgets and Plugins with PHP, Drew Falkman teaches PHP developers how to create custom functionality for WordPress 2.0 through 3.0 using widgets and plugins. This course starts by installing and setting up WordPress 3.0 on both Mac and Windows, then provides an in-depth look at tasks related to these WordPress add-ons: installing and administering, building and customizing, creating editable options and database tables, working with posts and pages, and utilizing jQuery and AJAX. There are also tutorials dedicated to promoting a widget or plugin, adding security, and localizing the interface. Exercise files are included with the course.
WordPress template tags are little custom functions that can be used by WordPress administrators in their themes and throughout their WordPress site to perform a bunch of tasks. Usually that's going to be getting and outputting something. More simply put: they're functions that can be used in WordPress templates. Sometimes they output authors or posts or categories or short links or something like that. For plugin developers, this is another way we can add functionality to WordPress, creating our own template tags. The Codex has some information about template tags, and it actually lists the template tags that are currently available inside of WordPress.
For example, here is one: bloginfo. You can use bloginfo to get different types of data inside of your WordPress blog. To use it, let's go ahead and log into our WordPress admin, and under Appearance, there is an option for Editor. This allows administrators to edit their themes directly, and you can see they can select which theme they want to edit-- In this case, Twenty Ten, which is the default theme that comes with WordPress 3.0--and we're going to choose Main Index Template. We'll scroll down to the bottom, and you can see they have some template tags in here that get the sidebar and get the footer, and we are going to add another one, bloginfo, and we are going to get description.
So, it's as simple as that. I update the file, which will save it, and I can go ahead and launch my blog site, and if I scroll down, you'll see at the bottom of the site, after the footer, I have my description. To create your own template tag, if you remember, every WordPress plugin file is included automatically in the request, which means not only is the code that isn't in function is included, the functions themselves are included. So, in this example, I have an add_copyright function. This will essentially become a template tag.
You can see it just outputs a little copyright message directly to the screen. So, if I want to use this, I can go back into my administrator, in the Edit Themes, I'll scroll down, and instead of outputting my blog description, I am going to use add_copyright. In order to make this work, I need to make sure that I first check on my plugin, My copyright plugin, and make sure that it's activated so that it's actually included in the file. Now that it's activated, I can go to the front-end of the web site and refresh, and you can see it's included my template tag with my copyright message.
WordPress allows us to build our own template tags. These are essentially functions that can be run via PHP from within any template in the WordPress environment. What's great about the plugin API is that any function in our plugin files will automatically be included in WordPress requests. So, everything you write can be used this way. The main thing is if you want to expose these functions to your administrative users, you need to make sure and provide some sort of documentation so they know what's there.
Find answers to the most frequently asked questions about WordPress: Creating Custom Widgets and Plugins with PHP.
Here are the FAQs that matched your search "":
Sorry, there are no matches for your search ""—to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.