Modifying core files is always a bad idea. It may create a security loophole. Also, you will have lost the modification when you upgrade your WordPress installation. Wordpress version releases r very fast :)
Hooks are one of the main building blocks of WordPress plug-ins. Almost every plug-in uses a hook to overwrite WordPress’ core functionality.
How to Use Hooks on Your WordPress Blog
Unless you’re writing a plug-in, you would write hooks in the functions.php file. This file is located in the wp-content/themes/yourtheme directory.
A hook, as you would expect, “hooks” one function to another. For example, you could write a custom function and attach it to one of WordPress’ core functions:
I will tell u a simple hook to understand the process:
Let whenever a post is done a mail alert should be sent to a mail:
first we need to name our function let it be mailalert
function mailalert()
{
mail('tamojyoti.bose@gmail.com','You got a post', 'Hello I am from ur blog we received a new post ');
}
add_action('publish_post','mailalert');
now what this thing did :
we all come across simple mail fn of php which i used to just drop a mail to me when a post is done.
add action is just hooking up core function publish_post with my one just created
Please comment:) This is my first writing so please pardon me if i m wrong
No comments:
Post a Comment