WordPress.org

Support

Support » How-To and Troubleshooting » is_single array not working

is_single array not working

  • I am trying to conditionally hide ads on certain posts. I’ve used both post ID’s and post slugs/titles and am no further ahead.

    The problem is that the following codes, added into the template file (single.php) only seem to either only acknowledge a single post ID or the first ID in a string. The array (which I am betting is syntactically correct) doesn’t work at all.

    this works – hides code on post ID #30:

    <code><?php if( !is_single('30') ) : ?>
    ~ ad code goes here ~
    <?php endif; ?></code>

    this partially works – hides code only post ID #30 but not on others:

    <?php if( !is_single(30,62,50,61,27,94,102,86,64,29,49 ))  : ?>
    ~ ad code goes here ~
    <?php endif; ?>

    this doesn’t work at all – returns blank page:

    <?php if( !is_single( array( 30,62,50,61,27,94,102,86,64,29,49 ) )  : ?>
    ~  ad code goes here ~
    <?php endif; ?>
  • The topic ‘is_single array not working’ is closed to new replies.
Skip to toolbar