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.
Was This Tutorial Helpful?