Using hooks to place content in theme dynamically

If you’re the parent theme Developer, you can add the hook in your parent themes file and then use it in a custom function in your child theme.

1. Add Hook To Parent Themes File

<?php do_action( 'after_wp_footer' ); ?>

2. Create Function For New Hook in Parent Theme

function create_after_footer_hook() {

do_action('after_wp_footer');

}

3. Add Hook In Custom Function Using Child Theme

function your_function_name() {

echo 'Replace this entire line of code with your code to do stuff';
}
add_action('after_wp_footer', 'your_function_name');

Leave a Comment