Return to Support

Put Slider on All Pages Except a Few

Home Forums Graphene WordPress theme Support Put Slider on All Pages Except a Few

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #8704
    Terry
    Member

    First – thank you SO much for a fantastic theme. So awesome, and so useful. You rock!

    I have checked the forums for an answer to my question, and I’ve spent a few hours trying to figure this out myself, so I thought I would ask you for some help.

    I’m trying to add the slider to all our pages, except a few. We are a law firm (http://goo.gl/F28nA6), and the majority of our pages describe our practice areas. I want the slider to show on those pages, just not the “contact us”, “about us”, “testimonials”, etc. I’m using the tutorial from Prassanna (thanks for the great tips – I love your site!). I know it’s because I have very limited knowledge working with PHP, but when I try to edit the conditional tags, my site breaks. I would LOVE to be able to add slider to all pages EXCEPT the ones I list, but I couldn’t find that option.

    Do you any of you have a quick answer?

    Thanks for your help!

    #41907
    Archmore
    Member

    Hello BigZan

    I don’t use sliders much personally so there might be an easier way of doing this.

    However One way to take out the Slider on specific pages is with custom CSS.

    You might already be using Custom CSS. (See display options)

    You are looking for this value:

    Quote:
    `#content .featured_slider, .container_16 #content .slider_post {

    width: 1180px;

    }`

    ADD:

    Quote:
    display: none;

    So you are left with:

    Quote:
    `#content .featured_slider, .container_16 #content .slider_post {

    width: 1180px;

    display: none;

    }`

    This disables the slider on ALL pages.

    Then you will need to add the slider back to the individual pages you want.

    Each page has it’s own CSS ID.

    For example if you wanted to add the slider back to your “Arson Lawyer Page”. This page has the CSS ID of .page-id-281

    You will need to override the CSS value that disabled the slider on all pages.

    You would add this value:

    Quote:
    `.page-id-281 #content .featured_slider, .container_16 #content .slider_post {

    display: block !important;

    }`

    Now the slider is re-enabled for this page only.

    Repeat this process for any additional pages.

    Hope that works / helps.

    -Dan

    #41908

    @archmore:

    Actually, it’s better to just disable it conditionally with CSS:

    .page-id-42 #content .featured_slider, .container_16 #content .slider_post {
    display: none;
    }

    To hide it on those pages that you want to hide it on. Hiding and then redisplaying something with custom CSS can create headaches down the road and can add to the server’s load.

    #41909

    @bigzan:

    Try the PHP not conditional:

    function graphene_display_slider(){
    if (is_single() || is_front_page() || !is_page( 245 )){
    graphene_slider();
    add_action('wp_footer', 'graphene_scrollable');
    }
    }

    Should keep it off your contact page.

    #41910
    Terry
    Member

    Thank you so much, Archmore and Ken! I got it working how I wanted. First, I added this to functions.php:

    function graphene_display_slider(){
    if (is_single() || is_front_page() || !is_page( 245 )){
    graphene_slider();
    add_action('wp_footer', 'graphene_scrollable');
    }
    }

    Then, I added this into the custom css for each page I didn’t want the slider to show, changing out the id for each one:

    .page-id-42 #content .featured_slider, .container_16 #content .slider_post {
    display: none;
    }

    I have one more question – is there a way to disable all those other pages using PHP? It seems a bit overkill to have to add the above code into the CSS for each page. It’s working perfectly as-is, but just want it to be the best it can be!

    Again, thank you both for your input – I apprcreiate it very much. 🙂

    #41911

    The css is unnecessary. You can simply keep adding pages using the pipe:

    if (is_single() || is_front_page() || !is_page( 245 ) || !is_page(34) || !is_page(78)){

    etc, just using the pages in question.

    #41912
    Terry
    Member

    Hi Ken,

    That’s what I thought, but when I used that code before, it continued to be on every page. I tried again as you suggested, and it’s doing the same thing. Any suggestions? Here’s the code I’m using:

    if (is_single() || is_front_page() || !is_page( 245 ) || !is_page( 1344 ) || !is_page( 1330 ) || !is_page( 1316 ) || !is_page( 16 ) || !is_page( 1031 ) || !is_page( 34 ) || !is_page( 319 ) || !is_page( 371 ) || !is_page( 367 ) || !is_page( 445 ) || !is_page( 142 )){

    – Susanna

    #41913
    Prasanna SP
    Member

    FYI, is_page() takes an array of page IDs.

    !is_page( array( 245, 1344, 1330, 1316, 16, 1031, 34, 319, 371, 367, 445, 142 ) )

    and,

    add_action('wp_footer', 'graphene_scrollable');

    is not needed any more. Need to update my post.

    #41914
    Terry
    Member

    @Prassanna – I actually tried the !is_page (array code earlier, before I even posted. But, I couldn’t get it to work without breaking the site. Sorry, I’m not very adept with PHP yet. 🙁 Here’s what I tried, and it breaks the site:

    <?php
    function graphene_display_slider(){
    if (is_single() || is_front_page() || !is_page( array( 245, 1344, 1330, 1316, 16, 1031, 34, 319, 371, 367, 445, 142 ) ) {
    graphene_slider();
    }
    }

    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' );
    ?>

    What am I doing wrong?

    Also, thanks for the heads up about the unnecessary code – I removed it. 🙂

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

You must be logged in to reply to this topic.