Adding Home Section 1 and 2 to all pages on Parallax Pro Theme

Step 1: Replace the current front-page.php file’s code:

/**
* This file adds the Home Page to the Parallax Pro Theme.
*
* @author StudioPress
* @package Parallax
* @subpackage Customizations
*/

add_action( 'genesis_meta', 'parallax_home_genesis_meta' );
/**
* Add widget support for homepage. If no widgets active, display the default loop.
*
*/
function parallax_home_genesis_meta() {

if ( is_active_sidebar( 'home-section-1' ) || is_active_sidebar( 'home-section-2' ) || is_active_sidebar( 'home-section-3' ) || is_active_sidebar( 'home-section-4' ) || is_active_sidebar( 'home-section-5' ) ) {

//* Add parallax-home body class
add_filter( 'body_class', 'parallax_body_class' );
function parallax_body_class( $classes ) {

$classes[] = 'parallax-home';
return $classes;

}

//* Force full width content layout
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );

//* Remove primary navigation
remove_action( 'genesis_before_content_sidebar_wrap', 'genesis_do_nav' );

//* Remove breadcrumbs
remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs');

//* Remove the default Genesis loop
remove_action( 'genesis_loop', 'genesis_do_loop' );

//* Add homepage widgets
add_action( 'genesis_loop', 'parallax_homepage_widgets' );

}
}

//* Add markup for homepage widgets
function parallax_homepage_widgets() {

genesis_widget_area( 'home-section-3', array(
'before' => '<div class="home-odd home-section-3 widget-area"><div class="wrap">',
'after' => '</div></div>',
) );

genesis_widget_area( 'home-section-4', array(
'before' => '<div class="home-even home-section-4 widget-area"><div class="wrap">',
'after' => '</div></div>',
) );

genesis_widget_area( 'home-section-5', array(
'before' => '<div class="home-odd home-section-5 widget-area"><div class="wrap">',
'after' => '</div></div>',
) );

}

genesis();

Step 2: Open your functions.php file and add the following code inside the parallax_enqueue_scripts_styles() function :

if ( ! wp_is_mobile() ) {

		wp_enqueue_script( 'parallax-script', get_bloginfo( 'stylesheet_directory' ) . '/js/parallax.js', array( 'jquery' ), '1.0.0' );

	}

So here is the complete code of parallax_enqueue_scripts_styles() function :

function parallax_enqueue_scripts_styles() {

  if ( ! wp_is_mobile() ) {

		wp_enqueue_script( 'parallax-script', get_bloginfo( 'stylesheet_directory' ) . '/js/parallax.js', array( 'jquery' ), '1.0.0' );

	}

	wp_enqueue_script( 'parallax-responsive-menu', get_bloginfo( 'stylesheet_directory' ) . '/js/responsive-menu.js', array( 'jquery' ), '1.0.0' );
	wp_enqueue_style( 'dashicons' );
	wp_enqueue_style( 'parallax-google-fonts', '//fonts.googleapis.com/css?family=Montserrat|Sorts+Mill+Goudy', array(), CHILD_THEME_VERSION );
  
}

Lastly add this new code in functions.php file :

//* Display Home Section 1 and Section 2 to all pages
add_action( 'genesis_after_header', 'parallax_home_section', 7 );
function parallax_home_section() {
if ( ( is_active_sidebar( 'home-section-1' ) || is_active_sidebar( 'home-section-2' ) ) && ( is_singular('page') || is_home() ) ) {
genesis_widget_area( 'home-section-1', array(
'before' => '<div class="home-odd home-section-1 widget-area"><div class="wrap">',
'after' => '</div></div>',
) );

genesis_widget_area( 'home-section-2', array(
'before' => '<div class="home-even home-section-2 widget-area"><div class="wrap">',
'after' => '</div></div>',
) );
}
}

All are done. Now browse your site and Home Section 1 & 2 will appear on all pages.

This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.