• Resolved joshuanovak

    (@joshuanovak)


    Hello!

    I know that the code below will remove ShiftNav on one page on my site:

    add_action( ‘wp_head’ , ‘remove_shiftnav’ );
    function remove_shiftnav(){
    if( is_page( 1380 ) ){
    remove_action( ‘wp_footer’, ‘shiftnav_direct_injection’ );
    }
    }

    How do I disable shiftnav on multiple pages though?

    Thank you,
    Josh

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author sevenspark

    (@sevenspark)

    Hi Josh,

    You would just adjust the conditional as needed.

    Here’s the documentation for is_page(): https://developer.www.ads-software.com/reference/functions/is_page/

    As you can see, you can pass it an array of IDs if you would like it to match multiple pages.

    Hope that helps,

    Chris

    Thread Starter joshuanovak

    (@joshuanovak)

    Hey Chris,

    Thanks!

    I had to build the array inside the Function. For some reason it would disable all of ShiftNav when the array was built outside of the code.

    add_action( 'wp_head' , 'remove_shiftnav' );
    function remove_shiftnav(){
        if( is_page(array(1638, 1013, 1278, 1502)) ){
            remove_action( 'wp_footer', 'shiftnav_direct_injection' );
        }
    }

    But thank you works great.

    Josh

    • This reply was modified 8 years, 1 month ago by joshuanovak.
    Plugin Author sevenspark

    (@sevenspark)

    Hi Josh,

    You’re welcome, glad it helped! Yes, due to variable scope, it’s simplest to define the array within the function. Due to the scope of the variable, if you defined the variable outside of the function, you were likely passing is_page() a null value (undefined variable), which would return true on every Page – therefore disabling ShiftNav on every page.

    Glad you got it sorted ??

    Best,

    Chris

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Disable on multiple’ is closed to new replies.