Saturday, 13 April 2013

Genesis Actions Hooks & Filters


To work with Genesis Framework on WordPress you should know about Genesis Actions Hooks & Filters Hooks. How to filter content placed in different hooks, and how to add elements using those hooks which are built in Genesis Framework. You can use the Plugin to see all of the Actions
Hooks and Filter Hooks. Download the plugin and install it, after activating the plugin see the top bar when viewing the site. click on Action Hooks or Filter Hooks to see the Hooks to work with. Genesis Visual Hooks Guide Plugin

What are actions Hooks & filters :

Hooks are the backbone of WordPress. They enable WordPress developers to “hook” into the WordPress workflow to change how it works without directly modifying the core code. If we talk about Genesis, it has a lot of Hooks to modify the look of the Theme, if you directly modify the genesis code then all the changes will be lost when newer version of Genesis will come. or you will never update which is not a good idea.

<?php wp_head(); ?> 


<?php wp_footer(); ?>

is the basic example of Hooks in wordpress Theme. for example you want to add some code to the footer of the theme you can add the following code in the functions.php to add the code to the footer of the WordPress theme view complete WordPress Hooks we can use add_action or do_action.

add_action ('wp_footer', 'my_footer_code');
    function my_footer_code() {
      echo 'This site is built using <a href="">Genesis Framework</a>.';

Genesis Visual Hooks:

Here is a quick guide to Genesis Visual Hooks. Genesis Visual Hooks
if we take a look at the top of the Genesi Theme we will find Site Title to filter the site title we will use the following code.

Add or Remove Genesis Action

Genesis Remove_action :

to remove an action use the following code

//remove site title
remove_action ( 'genesis_site_title', 'genesis_seo_site_title' );

Genesis Add_action :

to add an action to genesis framework we use the following code.

// add custom site title
add_action ( 'genesis_site_title', 'my_site_title' );
    function my_site_title() {
      echo '<h1><img src="images/logo.png" alt="Site Title" /></h1>';

No comments:

Post a Comment