Summary Of Hooks In The WP Astra WordPress Theme
In the Astra theme for WordPress, you can customize the layout of your site by reordering the title below the featured image using theme hooks. This involves removing the title from its default position and adding it to a new location within the theme’s structure. The process is straightforward: first, you remove the default title action using the remove_action
function. Then, you use the add_action
function to place the title below the featured image by hooking into the appropriate Astra theme action. This customization can be implemented by adding a specific code snippet to your theme’s functions.php
file or a custom plugin, ensuring the title appears below the featured image on single post pages. This method leverages Astra’s hooks and WordPress’s action and filter system, allowing for easy and effective layout customization.
List of WordPress Astra Theme Hooks
Here is a comprehensive list of hooks provided by the Astra theme:
Header Hooks
astra_html_before
astra_body_top
astra_header_before
astra_header
astra_header_after
astra_content_before
astra_content_top
Content Hooks
astra_content_before
astra_content_top
astra_primary_content_top
astra_primary_content_bottom
astra_content_bottom
astra_footer_content
Blog Hooks
astra_primary_content_top
astra_primary_content_bottom
astra_entry_before
astra_entry_top
astra_entry_content_before
astra_entry_content_after
astra_entry_bottom
astra_entry_after
Sidebar Hooks
astra_sidebars_before
astra_sidebars_after
Footer Hooks
astra_footer_before
astra_footer
astra_footer_after
Comments Hooks
astra_comment
astra_comment_form_before
astra_comment_form_after
Example of Reordering the Title Below the Featured Image
To reorder the title below the featured image in the Astra theme, you can use the following code in your theme’s functions.php
file or a custom plugin:
// Remove the title from its original position
add_action('wp', 'move_astra_title_below_featured_image');
function move_astra_title_below_featured_image() {
// Remove the default Astra title action
remove_action('astra_entry_header', 'astra_entry_header_markup');
// Add custom function to display title below the featured image
add_action('astra_entry_content_before', 'custom_astra_entry_header_markup');
}
function custom_astra_entry_header_markup() {
// Ensure this only applies to single posts
if (is_singular('post')) {
// Get the title
astra_entry_header_markup();
}
}
Notes:
This basic script, CSS style, and plugin are designed to function optimally assuming minimal interference from your theme or other plugins. If conflicts occur or further customization is needed, additional adjustments may be necessary. Please note that this script, CSS style, or plugin must be used AS IS.
Wp Scriptly
Comments: