Community Forums › Forums › Archived Forums › General Discussion › Adding widgets to News Pro Home
- This topic has 3 replies, 2 voices, and was last updated 7 years, 8 months ago by
chikamiku.
-
AuthorPosts
-
September 25, 2015 at 4:52 pm #166683
chikamiku
ParticipantI am running a news aggregator website on a certain topics. Is it possible for me to achieve the following with News pro theme?
- add a Home Center widget below the Home Left and Home Right which would cover the whole length of the above two widgets combined
- Repeat the Home Left and Home Right widget just below the Home Center widget
Thamlnk you all and I hope you guys could me do the above.
Regards
September 25, 2015 at 9:22 pm #166696Victor Font
ModeratorFirst you need to register the widget areas. Add this to functions.php:
genesis_register_sidebar( array( 'id' => 'home-center', 'name' => __( 'Home - center', 'news' ), 'description' => __( 'This is the center section of the homepage.', 'news' ), ) ); genesis_register_sidebar( array( 'id' => 'home-middle-left-2', 'name' => __( 'Home - Middle Left 2', 'news' ), 'description' => __( 'This is the second middle left section of the homepage.', 'news' ), ) ); genesis_register_sidebar( array( 'id' => 'home-middle-right-2', 'name' => __( 'Home - Middle Right 2', 'news' ), 'description' => __( 'This is the second middle right section of the homepage.', 'news' ), ) );
Next, you have to modify the home page. Open front-page.php and replace it with this code:
<?php /** * This file adds the Home Page to the News Pro Theme. * * @author StudioPress * @package News Pro * @subpackage Customizations */ add_action( 'genesis_meta', 'news_home_genesis_meta' ); /** * Add widget support for homepage. If no widgets active, display the default loop. * */ function news_home_genesis_meta() { if ( is_active_sidebar( 'home-top' ) || is_active_sidebar( 'home-middle-left' ) || is_active_sidebar( 'home-middle-right' ) || is_active_sidebar( 'home-center' ) || is_active_sidebar( 'home-middle-left-2' ) || is_active_sidebar( 'home-middle-right-2' ) ||is_active_sidebar( 'home-bottom' ) ) { // Force content-sidebar layout setting // add_filter( 'genesis_site_layout', '__genesis_return_content_sidebar' ); //* Force full-width-content layout add_filter( 'genesis_site_layout', '__genesis_return_full_width_content' ); // Add news-home body class add_filter( 'body_class', 'news_body_class' ); } 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-right' ) || is_active_sidebar( 'home-bottom' ) ) { // Remove the default Genesis loop remove_action( 'genesis_loop', 'genesis_do_loop' ); // Add homepage widgets add_action( 'genesis_loop', 'news_homepage_widgets' ); } } function news_body_class( $classes ) { $classes[] = 'news-pro-home'; return $classes; } function news_excerpt_length( $length ) { return 25; // pull first 50 words } function news_top_excerpt_length() { add_filter( 'excerpt_length', 'news_excerpt_length' ); } function news_remove_top_excerpt_length() { remove_filter( 'excerpt_length', 'news_excerpt_length' ); } function news_homepage_top_widget() { genesis_widget_area( 'home-top', array( 'before' => '<div class="home-top widget-area">', 'after' => '</div>', ) ); } function news_homepage_widgets() { if ( is_active_sidebar( 'home-middle-left' ) || is_active_sidebar( 'home-middle-right' ) ) { echo '<div class="home-middle">'; genesis_widget_area( 'home-middle-left', array( 'before' => '<div class="home-middle-left widget-area">', 'after' => '</div>', ) ); genesis_widget_area( 'home-middle-right', array( 'before' => '<div class="home-middle-right widget-area">', 'after' => '</div>', ) ); echo '</div>'; } if ( is_active_sidebar( 'home-center' ) ) { genesis_widget_area( 'home-center', array( 'before' => '<div class="home-center widget-area">', 'after' => '</div>', ) ); } if ( is_active_sidebar( 'home-middle-left-2' ) || is_active_sidebar( 'home-middle-right-2' ) ) { echo '<div class="home-middle-2">'; genesis_widget_area( 'home-middle-left-2', array( 'before' => '<div class="home-middle-left widget-area">', 'after' => '</div>', ) ); genesis_widget_area( 'home-middle-right-2', array( 'before' => '<div class="home-middle-right widget-area">', 'after' => '</div>', ) ); echo '</div>'; } genesis_widget_area( 'home-bottom', array( 'before' => '<div class="home-bottom widget-area">', 'after' => '</div>', ) ); } genesis();
Last you have to apply the CSS.
Find the classes for the home page in style.css around line 1287 and replace them with this:
/* Home Page --------------------------------------------- */ .home-top { background-color: #f3f3f3; border-bottom: 1px solid #e3e3e3; clear: both; padding: 20px 20px 0; } .home-top .featured-content .entry-title { font-size: 30px; } .home-middle-left, .home-middle-left-2 { border-right: 1px solid #e3e3e3; float: left; padding: 20px 20px 0; width: 50%; } .home-middle-right, .home-middle-right-2 { float: right; padding: 20px 20px 0; width: 50%; } .home-bottom, .home-center { border-top: 1px solid #e3e3e3; clear: both; padding: 20px 20px 0; }
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?September 26, 2015 at 10:29 pm #166744chikamiku
ParticipantThis reply has been marked as private.September 26, 2015 at 10:31 pm #166745chikamiku
ParticipantVictor,
Sorry to bother you again. The latest style sheet looks like the following. It may provide any clue on how to resolve the columns-related issue.(edited to remove the stylesheet... there is no need to add the whole content of the stylesheet here)
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.