Community Forums › Forums › Archived Forums › Design Tips and Tricks › News Pro – How to duplicate home page widget areas
- This topic has 3 replies, 2 voices, and was last updated 5 years, 1 month ago by buddy_boy8403.
-
AuthorPosts
-
March 15, 2019 at 7:40 am #490079buddy_boy8403Participant
I would like to duplicate the Home - Top, Home - Middle Left, Home - Middle Right, and Home - Bottom widget areas further down on the page, essentially doubling the amount of content that can be shared on the home page. I don't want to add content to what is already there - I want to duplicate the main genesis content so the Home - Top is both at the top of the page and also down further below the Home - Bottom, and continue duplicating all home widgets until I have a whole other section of content I can display further down the home page. Hopefully I'm explaining this right. Let me know if there are questions about what I'm trying to achieve, and thank you for your help!
https://continentalenews.comMarch 15, 2019 at 8:01 am #490080Victor FontModeratorYou have to define the new widget areas in functions.php. The current widget area definitions are near the bottom of the file. You define them with the genesis_register_sidebar() function. Just follow the examples that are already there.
Then, you have to display them in front-page.php. Modify the news_home_genesis_meta() function to check if they have content. Then, modify the news_homepage_widgets() functions to display them.
You can't duplicate them exactly because their names must be unique.
Also, don't use the WordPress editor to modify PHP. If you make a mistake with just 1 character, you'll bring your site down and will have to fix things through FTP. It's best to use FTP in the first place and edit the files in your local environment with a real editor.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?March 18, 2019 at 12:32 pm #490118buddy_boy8403ParticipantVictor:
I'm having trouble with this. Is there a tutorial somewhere that walks through these steps as an example specific to the News Pro theme?
March 18, 2019 at 2:24 pm #490121buddy_boy8403ParticipantI've added the following to functions.php:
//Adam- Register widget areas to duplicate top home page genesis_register_sidebar( array( 'id' => 'home-top-lower', 'name' => __( 'Home - Top - Lower', 'news-pro' ), 'description' => __( 'This is the lower top section of the homepage.', 'news-pro' ), ) ); genesis_register_sidebar( array( 'id' => 'home-middle-left-lower', 'name' => __( 'Home - Middle Left - Lower', 'news-pro' ), 'description' => __( 'This is the lower middle left section of the homepage.', 'news-pro' ), ) ); genesis_register_sidebar( array( 'id' => 'home-middle-right-lower', 'name' => __( 'Home - Middle Right - Lower', 'news-pro' ), 'description' => __( 'This is the lower middle right section of the homepage.', 'news-pro' ), ) ); genesis_register_sidebar( array( 'id' => 'home-bottom-lower', 'name' => __( 'Home - Bottom - Lower', 'news-pro' ), 'description' => __( 'This is the lower bottom section of the homepage.', 'news-pro' ), ) );
Modified the function news_home_genesis_meta() in front-page.php to:
if ( is_active_sidebar( 'home-top' ) || is_active_sidebar( 'home-top-lower' ) || is_active_sidebar( 'home-middle-left' ) || is_active_sidebar( 'home-middle-left-lower' ) || is_active_sidebar( 'home-middle-right' ) || is_active_sidebar( 'home-middle-right-lower' ) || is_active_sidebar( 'home-bottom' ) || is_active_sidebar( 'home-bottom-lower' ) ) { // Force content-sidebar layout setting. add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' ); // Add news-home body class. add_filter( 'body_class', 'news_body_class' ); // Add content heading. add_action( 'genesis_before_loop', 'news_content_heading' ); } if ( is_active_sidebar( 'home-top' ) ) { // Add excerpt length filter. add_action( 'genesis_before_loop', 'news_top_excerpt_length' ); // Add homepage widgets. add_action( 'genesis_before_loop', 'news_homepage_top_widget' ); // Remove excerpt length filter. add_action( 'genesis_before_loop', 'news_remove_top_excerpt_length' ); } if ( is_active_sidebar( 'home-middle-left' ) || is_active_sidebar( 'home-middle-left-lower' ) || is_active_sidebar( 'home-middle-right' ) || is_active_sidebar( 'home-middle-right-lower' ) || is_active_sidebar( 'home-bottom' ) || is_active_sidebar( 'home-bottom-lower' ) || is_active_sidebar( 'home-top-lower' ) ) { // Remove the default Genesis loop. remove_action( 'genesis_loop', 'genesis_do_loop' ); // Add homepage widgets. add_action( 'genesis_loop', 'news_homepage_widgets' ); } }
And used the following to output the widget areas in front-page.php:
// Output the home-top-lower widget area. function news_homepage_top_lower_widget() { genesis_widget_area( 'home-top-lower', array( 'before' => '<div class="home-top-lower widget-area">', 'after' => '</div>', ) ); } // Output the home-middle and home-bottom widget areas. function news_homepage_lower_widgets() { if ( is_active_sidebar( 'home-middle-left-lower' ) || is_active_sidebar( 'home-middle-right-lower' ) ) { echo '<div class="home-middle-lower">'; genesis_widget_area( 'home-middle-left-lower', array( 'before' => '<div class="home-middle-left-lower widget-area">', 'after' => '</div>', ) ); genesis_widget_area( 'home-middle-right-lower', array( 'before' => '<div class="home-middle-right-lower widget-area">', 'after' => '</div>', ) ); echo '</div>'; } genesis_widget_area( 'home-bottom-lower', array( 'before' => '<div class="home-bottom-lower widget-area">', 'after' => '</div>', ) ); }
No php errors are thrown on the page, and the new widget areas do show in the back end. When I add content to them, nothing displays on the home page. Tried deleting cache and reloading the page - nada. When I try to follow other tutorials I find online, the site breaks. Can you tell me what I'm doing wrong? Again, the objective is to duplicate the four News Pro widget areas further on down the page using the exact same styling.
-
AuthorPosts
- The topic ‘News Pro – How to duplicate home page widget areas’ is closed to new replies.