Skip to content

Instantly share code, notes, and snippets.

@devuri
Last active February 14, 2018 23:54
Show Gist options
  • Save devuri/b19b508aa7b1f75ee9bfd845140cb1fd to your computer and use it in GitHub Desktop.
Save devuri/b19b508aa7b1f75ee9bfd845140cb1fd to your computer and use it in GitHub Desktop.
WordPress Action Hook Example
<?php
// https://stackoverflow.com/questions/26781857/how-do-do-action-and-add-action-work
do_action( 'my_footer_hook' );
add_action( 'my_footer_hook', 'my_footer_echo' );
function my_footer_echo(){
echo 'hello world';
}
<?php
/**
* Creating an action Hook for Worpdress
* call action liek so do_action( 'zipfooter_credit' );
*/
if ( ! function_exists( 'zipteq_footer_credit_info' ) ) :
function zip_footer_credit_info(){
$footer_credit = '<div class="site-info">';
$footer_credit .= get_bloginfo( 'name' );
$footer_credit .= ' - ' .get_bloginfo( 'description' );
$footer_credit .= '</div><!-- .site-info -->';
echo $footer_credit;
}
endif;
add_action( 'zipfooter_credit', 'zip_footer_credit_info', 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment