Sunday 1 October 2017

Modern WordPress Theme Development With Action Hooks


Developing excellent WordPress themes is an actual challenge. But even the seemingly easy adjusting of existing themes can become pretty tough pretty fast. More and more developers use action hooks in their template files, as they help to keep a clear overview of the individual files, as well as the used functions. As there is very little information on working with action hooks out there, beginners and advanced users alike tend to run out of ideas quickly.
WordPress Action Hooks – an Introduction
To prevent that from happening to you, today, we’ll look into action hooks and their advantages, to save you from these frustrations.
If you want to open a WooCommerce shop, you may consider adjusting the popular Storefront theme to your needs. After opening the template file for the display of the start page, this is what you’ll see:
As you can see, there are no loops in this file. Other theme files of Storefront are designed like this, too. However, these files could be cleaned up even more:
Here, a single action hook takes care of the display of the star page’s content.
<?php do_action( ‘homepage’ ); ?>
The Principle of the WordPress Action Hooks
The principle
Source: https://managewp.org/articles/16225/modern-wordpress-theme-development-with-action-hooks




source https://williechiu40.wordpress.com/2017/10/01/modern-wordpress-theme-development-with-action-hooks/

No comments:

Post a Comment