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. 

05:44 by Unknown · 0

Wordpress hooks for Adding scripts with it


Wordpress has built in Javascripts and few other built in functions like plupload, tinymce, swf, simplepie, thivkbox  and  jQuery. There also you can add your custom scripts into it. here i will guide you to add your custom script into your WordPress theme. 


There are two possible sides to add your script. 
1. Admin end or Back end
2. Front end 

1. If you want add your custom script into wordpress admin page , you can add it in two areas. Header and footer sides.

Now if you want your script to run in header of your wordpress admin. just use this acction hook.

Before that save your custom script into a directory. than use this action script

add_action('admin_head', 'your script_function_name');

and also admin_footer for footer scripts. 

2. Front end scripts.

use this action on you theme functions.php or your plugin file

add_action('wp-head', 'your function_name_here');

also front end footer scripts

add_action('wp_footer' , 'your_function_name_here');

thats it to add your custom scrips into WordPress

07:40 by Unknown · 0

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