• I have this code that works for 1 specific page which is the Portfolio.

    <?php if ($post->ID != 20 && get_post_type() != ‘portfolio’)
    get_sidebar();?>

    I want to know how do I add extra pages to it?

    thank you ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • You need to test for additional ids. You could use:
    if ( ( $post->ID != 20 && $post->ID != 54 ) && get_post_type() != 'portfolio')

    but that could quickly get clumsy and difficult to edit if you want to add quite a few pages. So something a little cleaner might look like:

    <?php
    $mypages = array( '20', '54', '78', '123');
    if ( in_array( $post->ID, $mypages ) && get_post_type() != 'portfolio')
    get_sidebar();?>
    Thread Starter Juztin

    (@juztin)

    it works but it gives me this error

    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ‘)

    Which code are you using?

    Thread Starter Juztin

    (@juztin)

    I used this code

    <?php
    $mypages = array( ’20’, ’54’, ’78’, 123′);
    if ( in_array( $post->ID, $mypages ) && get_post_type() != ‘portfolio’)
    get_sidebar();?>

    Thread Starter Juztin

    (@juztin)

    I did use this code:

    if ( ( $post->ID != 20 && $post->ID != 54 ) && get_post_type() != ‘portfolio’)

    and it works fine

    thanks ??

    And what line is causing the error in that code? Also, you do know I made all of those page ids up? You need to replace them with the ids that you want.

    Thread Starter Juztin

    (@juztin)

    I did replace them with the code that I wanted

    as for what line is causing the error

    it is this line

    if ( in_array( $post->ID, $mypages ) && get_post_type() != ‘portfolio’)

    Thanks for the help ??

    Make sure that each of your page ids in the $mypages array has both opening and closing single quotes (‘).

    Thread Starter Juztin

    (@juztin)

    Nice
    will try that

    Thanks for your help ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How to delete sidebar from several pages’ is closed to new replies.