Created
May 17, 2018 13:39
-
-
Save anwerashif/bc82ce3b5ece8c8db9de21d945b70a95 to your computer and use it in GitHub Desktop.
Creating Custom Front Page Template Design for Blog in Genesis >> https://rainastudio.com/custom-front-page-template-design/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Front Page. | |
* | |
* @package StudioPlayer | |
* @link https://rainastudio.com/themes/studioplayer | |
* @author RainaStudio | |
* @copyright Copyright © 2018 RainaStudio | |
* @license GPL-2.0+ | |
*/ | |
// Check if any front page widgets are active. | |
if ( is_active_sidebar( 'home-featured-widget' ) || | |
is_active_sidebar( 'featured-review-widget' ) || | |
is_active_sidebar( 'latest-blog-widget' ) || | |
is_active_sidebar( 'frontpage-cta-widget' ) || | |
is_active_sidebar( 'home-last-widget' ) ) { | |
// Additional body class | |
add_filter( 'genesis_attr_body', 'studio_player_siteinner_attr' ); | |
function studio_player_siteinner_attr( $attributes ) { | |
// Add a class of 'front-page-blog' for styling this .site-inner differently | |
$attributes['class'] .= ' front-page-blog'; | |
// Add an id of 'genesis-content' for accessible skip links | |
$attributes['id'] = 'studioplayer_home'; | |
// Add the attributes from .entry, since this replaces the main entry | |
$attributes = wp_parse_args( $attributes, genesis_attributes_entry( array() ) ); | |
return $attributes; | |
} | |
// Force full-width-content layout. | |
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' ); | |
// Add featured widget area to page header. | |
add_action('genesis_before_content_sidebar_wrap', 'studio_player_home_featured_widget'); | |
function studio_player_home_featured_widget() { | |
if ( is_active_sidebar('home-featured-widget')) { | |
// Front page 1 widget area. | |
genesis_widget_area( 'home-featured-widget', array( | |
'before' => '<div class="home-featured-widget overlay" role="banner"><div class="wrap">', | |
'after' => '</div></div>', | |
) ); | |
} | |
/* | |
* RainaStudio Featured Resources | |
* @author RainaStudio | |
* @link https://rainastudio.com | |
*/ | |
echo '<div class="featured-resources">'; | |
?> | |
<div class="wrap"> | |
<div class="one-sixth first des-text">Featured Resources</div> | |
<div class="one-sixth "><i class="fa fa-stack-overflow" title="Stack Overflow"></i></div> | |
<div class="one-sixth "><i class="fa fa-github" title="Github"></i></div> | |
<div class="one-sixth "><i class="fa fa-wpbeginner" title="WPBeginner"></i></div> | |
<div class="one-sixth "><i class="fa fa-wikipedia-w" title="Wikipedia"></i></div> | |
<div class="one-sixth "><i class="fa fa-reddit-alien" title="Reddit"></i></div> | |
</div></div> | |
<?php | |
} | |
// Remove default loop. | |
remove_action( 'genesis_loop', 'genesis_do_loop' ); | |
add_action( 'genesis_loop', 'studio_player_front_page_loop' ); | |
/** | |
* Front page content. | |
* | |
* @since 2.0.0 | |
* | |
* @return void | |
*/ | |
function studio_player_front_page_loop() { | |
// Rest of front page widget areas | |
echo '<div class="wrap post-content">'; ?> | |
<div class="one-half first"> | |
<div class="widget-heading"><span class="color-studio">Featured</span> Tools Review</div> | |
<?php | |
// Front page 2 widget area. | |
genesis_widget_area( 'featured-review-widget', array ( | |
'before' => '<div class="featured-review-widget widget-area"><div class="wrap">', | |
'after' => '</div></div>', | |
) ); | |
?> | |
</div> | |
<div class="one-half "> | |
<div class="widget-heading"><span class="color-studio">Latest</span> From Blog</div> | |
<?php | |
// Front page 3 widget area. | |
genesis_widget_area( 'latest-blog-widget', array ( | |
'before' => '<div class="latest-blog-widget widget-area"><div class="wrap">', | |
'after' => '</div></div>', | |
)); | |
?> | |
</div> | |
</div> | |
<div class="wrap"> | |
<?php | |
// Front page 4 widget area. | |
genesis_widget_area( 'frontpage-cta-widget', array ( | |
'before' => '<div id="frontpage_cta_widget" class="widget-area frontpage-cta-widget"><div class="wrap">', | |
'after' => '</div></div>', | |
)); | |
?> | |
<div class="last-content"> | |
<div class="widget-heading"><span class="color-studio">WordPress And Genesis Framework</span> Tutorials For Beginners</div> | |
<?php | |
// Front page 5 widget area. | |
genesis_widget_area( 'home-last-widget', array ( | |
'before' => '<div id="home-last-widget" class="widget-area home-last-widget"><div class="wrap">', | |
'after' => '</div></div>', | |
) ); | |
?> | |
</div> | |
</div> | |
<?php | |
} | |
} | |
// Run Genesis. | |
genesis(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment