Namecheap.com - Cheap domain name registration, renewal and transfers - Free SSL Certificates - Web Hosting

Working with WordPress Custom Hooks


WordPress Action Hooks
Every developer must know about wordpress hooks . Its classified as two area based on its usage and necessity. here it is

  1. Action hooks and
  2. Filter hooks.

Both are doing much quite similar jobs but having small differences.

First of all we must know what is action hooks and how it is organised with wordpress.?
  
Its not just a simple thing behind your wordpress CMS. Its works more with database tables, template files , custom codes of plugin and themes.  

So each and every action are performed through the code and functions.  for every functions have certain priority and time to perform its operations. so it's all hooked with this functions .

now we can use its built in hooks or else we can code it for our own. as always we know wordpress is blend like a shapeless objects. so you can blend its features based on your needs. 

you can find the list of wordpress hooks from wordpress codex. 

Also you can create a new one for your custom usage. 
 creation of custom hooks need the following steps. 

1. create your code with a your desired function name .

2. add your function with wordpress action hooks like the following line


  add_action('custom_hook_name', 'your_custom_function_name'); 


the above code hook your function with wordpress. 

3. than write your custom hook's function where you want to use it on your wordpress cms. 

The following code help you create your custom hooks function. 


   function custom_hook_name() {
         do_action('custom_hook_name');
   }
 
Thats it for emerging of your wordpress custom hooks for your custom operation. Any comments and feedback requested from you reader. 

0 Responses to “Working with WordPress Custom Hooks”

Post a Comment

Namecheap.com - Cheap domain name registration, renewal and transfers - Free SSL Certificates - Web Hosting