Putting slider on specific pages

  • jezclifton

    #3958

    Hi there,

    Following Prasanna’s guide here:

    I’m trying to set up the slider to appear, as on the homepage of http://www.beverleygrammar.co.uk/news on specific pages throughout the site.

    I’ve put all 3 sections of code in the functions.php file of my child theme, but, although the slider shows up, it still does so on every page of the site, and with no content! (also static).

    This is probably my coding skills at fault, I wondered if someone could point me in the right direction:

    <?php function graphene_display_slider(){ graphene_slider();
    add_action('wp_footer', 'graphene_scrollable'); } ?>

    <? function custom_enqueue_scripts(){
    if ( ! is_admin() ) { // Front-end only
    wp_enqueue_script( 'graphene-jquery-tools' ); // jQuery Tools, required for slider
    }
    }
    add_action( 'wp_enqueue_scripts', 'custom_enqueue_scripts' ); ?>

    <? function graphene_display_slider(){
    if (is_front_page()){
    graphene_slider();
    add_action('wp_footer', 'graphene_scrollable');}
    } ?>

    Anonymous

    #26757

    Please put your code between backticks. This key is located above the Tab. I’ve corrected your post.

    Your code is faulty. You shouldn’t use graphene_display_slider() function twice.

    Try this,

    <?
    function graphene_display_slider(){
    if (is_front_page() || is_page(PAGE_IDs)){
    graphene_slider();
    add_action('wp_footer', 'graphene_scrollable');}
    }

    function custom_enqueue_scripts(){
    if ( ! is_admin() ) { // Front-end only
    wp_enqueue_script( 'graphene-jquery-tools' ); // jQuery Tools, required for slider
    }
    }
    add_action( 'wp_enqueue_scripts', 'custom_enqueue_scripts' );
    ?>

    Replace PAGE_IDs with the IDs of the pages where you want to display slider. Comma separated for multiple page IDs. You can use Page slug or Page title instead of Page IDs. If you want to use page slug or page title, put them between single quotes,

    Example – IDs : is_page(12,15,96,78)

    Example – Page slug : is_page('welcome','contact-us')

    Example – Page title : is_single{'Welcome','Contact Us')

    jezclifton

    #26758

    Thanks for your reply. I understand where I went wrong!

    My code now looks like this

    <?
    function graphene_display_slider(){
    if (is_front_page() || is_single('Intranet')){
    graphene_slider();
    add_action('wp_footer', 'graphene_scrollable');}
    }

    function custom_enqueue_scripts(){
    if ( ! is_admin() ) { // Front-end only
    wp_enqueue_script( 'graphene-jquery-tools' ); // jQuery Tools, required for slider
    }
    }
    add_action( 'wp_enqueue_scripts', 'custom_enqueue_scripts' );
    ?>

    I’m intending, at the moment, to only have the slider on my static front page, and one additional page – entitled ‘Intranet’. This page is published at http://www.beverleygrammar.co.uk/news/index.php/intranet but is still not showing the slider. Your help is much appreciated!

    Anonymous

    #26759

    “Intranet” in your site is a page not post. So, you have to use is_page('Intranet') not is_single('Intranet')

    Change your permalink structure.

    jezclifton

    #26760

    Thanks. I’ve tried it both ways and am still unable to get the slider to show.

    My permalink structure is set to ‘Post Name’, should I change this? I also tried the conditional tag with the ID (when editing the Intranet page, the URL shows post=1225) and that doesn’t work either!

    Am I missing something?

    Anonymous

    #26761

    There shouldn’t be index.php in URL if you set permalink structure to Post name.

    Try this,

    <?
    function graphene_display_slider(){
    if (is_front_page() || is_page(1225)){
    graphene_slider();
    add_action('wp_footer', 'graphene_scrollable');}
    }

    function custom_enqueue_scripts(){
    if ( ! is_admin() ) { // Front-end only
    wp_enqueue_script( 'graphene-jquery-tools' ); // jQuery Tools, required for slider
    }
    }
    add_action( 'wp_enqueue_scripts', 'custom_enqueue_scripts' );
    ?>

    If nothing works, you could take a chance by giving me temporary access to your wp-admin area! I’ll try to fix it.

    jezclifton

    #26762

    That would be great! Is there some way I can send you some login credentials privately?

    Anonymous

    #26763

    Make use of my Contact form – http://www.prasannasp.net/contact/

    jezclifton

    #26764

    Message sent, thankyou.

Viewing 9 posts - 1 through 9 (of 9 total)

  • You must be logged in to reply to this topic.