• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2787

Original Genesis & WooCommerce Tutorials & 6000+ Guaranteed Code

Snippets

  • Try Premium
  • Log in

Academy Pro Slider Before Header

This code enables you to add the Soliloquy slider before the header to any Genesis child theme.

Tested using the Academy Pro & Genesis Sample child themes by StudioPress.

Installation Guide

There’s 2 steps :

Step 1 : Install the Soliloquy slider and create a slider named Slider.

Step 2 : Add the following PHP code to the end of your child themes functions file.

add_action( 'genesis_before_header', 'add_slider' );

function add_slider() {

if ( function_exists( 'soliloquy' ) ) { 

soliloquy( 'slider', 'slug' ); 

    }

}

Video Installation Guide

Shows you how to install, setup and add the code required to display the slider in different positions and on specific pages in any Genesis child theme.

Change Position of Slider

Change the genesis_before_header hook in the above code to any other Genesis hook like this example which changes the hook to genesis_after_header :

add_filter( 'genesis_after_header', 'add_slider' );

function add_slider() {

if ( function_exists( 'soliloquy' ) ) { 

soliloquy( 'slider', 'slug' ); 

    }

}

Only Show Slider On Specific Pages

Add any conditional tag to the code like this :

add_filter( 'genesis_before_header', 'add_slider' );

function add_slider() {

if ( ! is_front_page() ) {
    return;
}

if ( function_exists( 'soliloquy' ) ) { 

soliloquy( 'slider', 'slug' ); 

    }

}

The above version of the code only displays the slider on the front page. Swap out the is_front_page() conditional tag with any other conditional to only show the slider on specific pages or posts.

Academy Pro Theme Slider

Reader Interactions

Comments

  1. Christopher Lemmer says

    March 29, 2018 at 11:44 am

    And why is a “filter” being used instead of a “hook”?

    Log in to Reply
    • Brad Dalton says

      March 29, 2018 at 11:35 pm

      Typo as i was also writing a filter function at the same time and copied the first 2 lines to save time when testing. I forgot to update the embedded code which i have now done. add_filter is also a filter hook which will work, but add_action is the correct method.

      Log in to Reply
  2. Christopher Lemmer says

    March 29, 2018 at 11:41 am

    if ( ! is_front_page() ) {
    return;
    }

    That to me reads, if Not True (!) that we are on the front page(is_front_page), then do nothing (return).

    Does that “return” cause the function to end, meaning that the second “if” statement never runs?

    Log in to Reply
    • Brad Dalton says

      March 29, 2018 at 11:22 pm

      Yes, if its not the front page then end execution so function_exists never runs.

      You can also write the code like this :

      add_action( 'genesis_before_header', 'add_slider' );
      
      function add_slider() {
      
      if ( function_exists( 'soliloquy' ) AND is_front_page() ) { 
      
      soliloquy( 'slider', 'slug' ); 
      
          }
      
      }
      Log in to Reply
      • Christopher Lemmer says

        March 30, 2018 at 9:32 am

        I see. Thanks!

        Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags
 

Loading Comments...
 

You must be logged in to post a comment.