Do you want to include a custom template when some condition is true? Say no more, there is an filter hook called template_include.
It is really simple, call the filter hook, check if the condition is true and return the full path to the new template file.
Read More “Load A Different Template”
In the Add New User Role post, we have created a new WordPress role with default WordPress capabilities.
In this how-to we will add new custom capability to the existing WordPress role Contributor. In other words, contributor will be able to sit at the kings table as a thank you for all the contributions that they made so far. ;)
Read More “Add Custom Capabilities To User Roles”
Roles! Roles? Yes, roles! But I’m not talking about the movie roles that I have been in, none actually. I’m talking about WordPress roles.
In WordPress you can create new roles with different capabilities and add users to it. Neat right? Hard to do? No!
Read More “Add New User Role”
The action hook that we are going to use for redirection is commonly misused for including custom page templates. The name of the hook may be misleading for some and there you go.
The hook that we are going to use is the perfect hook to use for page redirections.
Read More “Redirect To A Different Page In WordPress”
WordPress has a cool little three functions that can help plugin developers do something when the plugin is activated, deactivated or uninstalled.
All three are equally important. If you use activation function to set up your plugin, you should also use at least one of the other two, deactivation or uninstall function. Something that most developers do not do. Result you might ask? A mess in options table. To the gallows with them. ;)
Read More “On Activation, Deactivation or Uninstall Functions”
Adding additional fields to the user profile in WordPress is a fairly easy job and requires calling four WordPress action hooks. Four action hooks?! Why? Keep on reading.
There are two action hooks for display the HTML and two hooks for saving the information.
Read More “Add Additional Fields To User Profile”
Yesterday I wanted to show page excerpt using get_posts on front page of a theme and of course came to the problem because WordPress does not create page excerpts by default.
So now what? Well the only way I could get page excerpt from a page is by using the excerpt field (not shown on page edit by default) or by automatically clean the content of the page, limit the number of words and output it.
Read More “Get WordPress Page Excerpt”