The Bizznis theme allows developers to change each and every aspect of it. This is done by using filter and action hooks, where developers can “hook” their changes to certain parts of the theme without editing Bizznis code directly. This is better because you still keep the parent theme code intact, but have freedom to change it where needed inside a child theme.
Action hooks
Actions are triggered by specific events that take place in WordPress and Bizznis. They allow you to hook your functions to locations in template files, where action hooks are available.
Learn more about action hooks.
1. Create a function that should execute when a specific event occurs.
The first step in creating an action in your child theme is to create a PHP function with the action functionality of Bizznis, and put it in a your child themes file (your child theme file must go into the wp-content/themes/your-child-theme directory). For example, if you want to display links to previous and next post, from a single post, you might define the following function:
function custom_prev_next_post_nav() {
if ( ! is_singular( 'post' ) ) {
return;
}
printf( '';
}
2. Hook this function to the event by using the add_action() function.
After your function is defined, the next step is to “hook” or register it with Bizznis. To do this, call add_action() in the global execution space of your child themes file:
add_action( 'bizznis_after_entry', 'custom_prev_next_post_nav' );
3. Put your PHP function in a template file.
The last step in getting your action hook to work is to put it into your child themes php file, usually “functions.php”, but can be any php template functions. The PHP function you wrote and the add_action call must go into a PHP file together, and the PHP file must be installed in the wp-content/themes/your-child-theme directory. All put together, it should look like this, when add to function.php file in your child themes root directory:
add_action( 'bizznis_after_entry', 'custom_prev_next_post_nav' ); function custom_prev_next_post_nav() { if ( ! is_singular( 'post' ) ) { return; } printf( ''; }
Filter hooks
Filters are functions that Bizznis passes data through, at certain points in execution, just before taking some action with the data (such as adding it to the database or sending it to the browser screen). Filters sit between the database and the browser (when WordPress is generating pages), and between the browser and the database (when WordPress is adding new posts and comments to the database); most input and output in Bizznis and WordPress passes through at least one filter. WordPress does some filtering by default, and your child theme can add its own filtering.
Learn more about filter hooks.
1. Create the PHP function that filters the data.
A filter function takes as input the unmodified data, and returns modified data (or in some cases, a null value to indicate the data should be deleted or disregarded). If the data is not modified by your filter, then the original data must be returned so that your child theme can continue to modify the value if necessary. The first step in creating a filter in your child theme is to create a PHP function and put it in a your child themes file (your child theme file must go into the wp-content/themes/your-child-theme directory). For example, if you want to filter the title of your posts, you might define the following function:
function custom_post_title( $title ) { return '' . $title . '
'; }
2. Hook in your filter in WordPress, by calling add_filter().
After your function is defined, the next step is to “hook” or register it with Bizznis. To do this, call add_filter() in the global execution space of your child themes file:
add_filter( 'bizznis_post_title_text', 'custom_post_title', 10, 1 );
3. Put your PHP function in a template file.
The last step in getting your filter hook to work is to put it into your child themes php file, usually “functions.php”, but can be any php template functions. The PHP function you wrote and the add_filter call must go into a PHP file together, and the PHP file must be installed in the wp-content/themes/your-child-theme directory. All put together, it should look like this, when add to function.php file in your child themes root directory:
add_filter( 'bizznis_post_title_text', 'custom_post_title', 10, 1 ); function custom_post_title( $title ) { return '' . $title . '
'; }