• Resolved Brandon_Orndorff

    (@brandon_orndorff)


    I am trying to exclude certain posts by ID from showing a plugin and in the conditional statement I have the following:

    !is_single( array(get_option('ignore_posts')) )

    with ignore_posts holding the array of numbers stored as 150,160,174,177

    The issue is that it works to exclude post with ID 150 but none after that. Also if I change the order to make post ID 160 first then 160 is the only one to function as expected.

    Thank you in advance for any insight you have.

Viewing 4 replies - 1 through 4 (of 4 total)
  • are you entering the array manually, or do the numbers come from some options or custom fields?

    i.e. are you absolutely sure you are using an array, or could it be a string with comma-separated numbers?

    Thread Starter Brandon_Orndorff

    (@brandon_orndorff)

    I am saving the numbers from a custom field in the admin area and calling them in with get_option(‘ignore_posts’)

    What is saved to the database is 150,160,174,177 //while testing

    So I guess is is a string with comma separated values

    You might need to explode the string into an array.

    $ignore = get_option( 'ignore_posts' );
    
    if ( ! is_array( $ignore ) )
        $ignore = explode( ',', $ignore );
    
     if ( ! is_single( $ignore ) ) {
         //.....
    Thread Starter Brandon_Orndorff

    (@brandon_orndorff)

    Perfect!

    Thank you both for your help, works great.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘!is_single(array()) Not Working’ is closed to new replies.