Summary Of Hooks In The WP Astra WordPress Theme

Blog- WpScriptly

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

  1. astra_html_before
  2. astra_body_top
  3. astra_header_before
  4. astra_header
  5. astra_header_after
  6. astra_content_before
  7. astra_content_top

Content Hooks

  1. astra_content_before
  2. astra_content_top
  3. astra_primary_content_top
  4. astra_primary_content_bottom
  5. astra_content_bottom
  6. astra_footer_content

Blog Hooks

  1. astra_primary_content_top
  2. astra_primary_content_bottom
  3. astra_entry_before
  4. astra_entry_top
  5. astra_entry_content_before
  6. astra_entry_content_after
  7. astra_entry_bottom
  8. astra_entry_after

Sidebar Hooks

  1. astra_sidebars_before
  2. astra_sidebars_after

Footer Hooks

  1. astra_footer_before
  2. astra_footer
  3. astra_footer_after

Comments Hooks

  1. astra_comment
  2. astra_comment_form_before
  3. 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:

Wp Scriptly

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

Newsletter Signup

WP Scriptly Newsletter

The WpScriptly Monthly newsletter offers top insights for WordPress pros: new scripts, plugins, resources, tips, tools, updates, and more every month.
*Wp Scriptly will not share or sell your name and email adress to anyone!

Comments: