How to re-order Action Hooks (Widgets)
-
Hi guys, I’m new to adjusting templates in WordPress. I have a problem with a template in that I would like to reorder the way Widgets are display on the front page.
I have found two places were the Wdigets (Action Hooks) are listed. First on the Genesis Child Theme, page_home_template.php and second on the functions.php template.
When reordering the action hooks from within the Functions.php file it does indeed reorder the Widgets from within WordPress > Widgets. However, this change of order is not represented on the front page of the website.
I’m clearly missing something here that I have not found in any Youtube vid or guide.
Code from child theme page-home-template:
// Execute Home Top Section
add_action( 'genesis_after_header', 'wsm_home_top');
function wsm_home_top() {
genesis_widget_area( 'slider', array( 'before' => '<div class="home-slider widget-area">', 'after' => '</div>') );
}add_action( 'genesis_after_header', 'wsm_home_featured', 15 );
function wsm_home_featured() {
genesis_widget_area( 'home-top-featured', array( 'before' => '<div class="home-top-featured widget-area"><div class="wrap">', 'after' => '</div></div>') );
}
// Remove the standard loop
remove_action( 'genesis_loop', 'genesis_do_loop' );// Execute Home Mid Section
add_action( 'genesis_loop', 'wsm_home_loop_helper' );
function wsm_home_loop_helper() {
echo'<div class="home-mid widget-area">';
genesis_widget_area( 'home-mid-left', array( 'before' => '<div class="mid-left widget-area">', 'after' => '</div>') );
genesis_widget_area( 'home-mid-center', array( 'before' => '<div class="mid-center widget-area">', 'after' => '</div>') );
genesis_widget_area( 'home-mid-right', array( 'before' => '<div class="mid-right widget-area">', 'after' => '</div>') );
echo'</div >';
}// Execute Home Bottom CTA
add_action( 'genesis_before_footer', 'caroline_home_bottom_cta', 5 );
function caroline_home_bottom_cta() {
genesis_widget_area( 'home-mid-cta', array( 'before' => '<div class="home-mid-cta widget-area"><div class="wrap">', 'after' => '</div></div>') );
}// Execute Home Bottom Section
add_action( 'genesis_before_footer', 'caroline_home_bottom', 8 );
function caroline_home_bottom() {
genesis_widget_area( 'home-bottom', array( 'before' => '<div class="home-bottom widget-area"><div class="wrap">', 'after' => '</div></div>') );
}genesis();
I can prioritize three of the action hooks, as you can see above - this does indeed change the order on the front page. However, I mainly want to move this action hook below the rest;
function wsm_home_loop_helper() {
echo'<div class="home-mid widget-area">';
genesis_widget_area( 'home-mid-left', array( 'before' => '<div class="mid-left widget-area">', 'after' => '</div>') );
genesis_widget_area( 'home-mid-center', array( 'before' => '<div class="mid-center widget-area">', 'after' => '</div>') );
genesis_widget_area( 'home-mid-right', array( 'before' => '<div class="mid-right widget-area">', 'after' => '</div>') );
echo'</div >';
}
But this does not provide a number to do so.The functions.php shows a list of the widgets as they appear in WordPress > appearance > plugins
// Setup Sidebars
unregister_sidebar( 'sidebar-alt' );
unregister_sidebar( 'header-right' );genesis_register_sidebar( array(
'id' => 'slider',
'name' => __( 'Slider', 'caroline' ),
'description' => __( 'This is thehome page image slider section.', 'caroline' ),
) );
genesis_register_sidebar( array(
'id' => 'home-top-featured',
'name' => __( 'Home Top - Featured Members', 'caroline' ),
'description' => __( 'This is the home page top featured section.', 'caroline' ),
) );
genesis_register_sidebar( array(
'id' => 'home-mid-left',
'name' => __( 'Home Mid Left', 'caroline' ),
'description' => __( 'This is the home page middle section.', 'caroline' ),
) );
genesis_register_sidebar( array(
'id' => 'home-mid-center',
'name' => __( 'Home Mid Center', 'caroline' ),
'description' => __( 'This is the home page middle section.', 'caroline' ),
) );
genesis_register_sidebar( array(
'id' => 'home-mid-right',
'name' => __( 'Home Mid Right', 'caroline' ),
'description' => __( 'This is the home page middle section.', 'caroline' ),
) );
genesis_register_sidebar( array(
'id' => 'home-mid-cta',
'name' => __( 'Home Middle - CTA', 'caroline' ),
'description' => __( 'This is the home page mid cta section.', 'caroline' ),
) );
genesis_register_sidebar( array(
'id' => 'home-bottom',
'name' => __( 'Home Bottom - Featured Articles', 'caroline' ),
'description' => __( 'This is the home page bottom section.', 'caroline' ),
) );
genesis_register_sidebar( array(
'id' => 'blog-sidebar',
'name' => __( 'Blog Sidebar', 'caroline' ),
'description' => __( 'This is the Blog Page Sidebar.', 'caroline' ),
) );
genesis_register_sidebar( array(
'id' => 'page-sidebar',
'name' => __( 'Page Sidebar', 'caroline' ),
'description' => __( 'This is the Page Sidebar.', 'caroline' ),
) );
genesis_register_sidebar( array(
'id' => 'community-sidebar',
'name' => __( 'Community Sidebar', 'caroline' ),
'description' => __( 'This is the Cummunity Page Sidebar.', 'caroline' ),
) );
genesis_register_sidebar( array(
'id' => 'courses-sidebar',
'name' => __( 'Courses Sidebar', 'caroline' ),
'description' => __( 'This is the Courses Page Sidebar.', 'caroline' ),
) );
genesis_register_sidebar( array(
'id' => 'shop-sidebar',
'name' => __( 'Shop Sidebar', 'caroline' ),
'description' => __( 'This is the Shop Page Sidebar.', 'caroline' ),
) );
When the order of these entires are change, it does indeed change the ordering from within WordPress, as I mentioned. However, these changes are not reflected on the home page.
So what am I missing here, there does not seem to be any other file that will allow me to reorder the Action Hooks (widgets) on the front page.
Thanks for your help,
SK
The topic ‘How to re-order Action Hooks (Widgets)’ is closed to new replies.