User Profile

Collapse

Profile Sidebar

Collapse
Cheyens
Cheyens
Last Activity: Aug 14 '13, 09:34 AM
Joined: Aug 11 '13
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Hi,

    I've managed to solve it like this:

    Code:
    <?php 
    if( get_field('materiale') )
    {
    	if( in_array( 'Red', get_field('materiale') ) )
    	{
    		echo '<a href="' . get_field('download') . '" target="_blank" class="readmore">Red →</a>';
    	}
    }
    ?>
    See more | Go to post

    Leave a comment:


  • Maybe this needs further explanation:

    I'm using Advanced Custom Fields Plugin with WordPress and this:

    /*
    * Conditional statement (Checkbox rvalue is an array)
    */

    Code:
    if( in_array( 'red', get_field('field_name') ) )
    {
        //...
    }
    But how do I make two if( in_array without getting the "Problem with Array (expects parameter 2 to be array) error if none of the two...
    See more | Go to post

    Leave a comment:


  • Cheyens
    started a topic Problem with Array (expects parameter 2 to be array)
    in PHP

    Problem with Array (expects parameter 2 to be array)

    Hi,

    This works as long one or both Checkboxes are checked:

    Code:
    <?php if( in_array( 'Red', get_field('materiale') ) ) {echo '<a href="' . get_field('download') . '" target="_blank" class="readmore">Red →</a>';}?> <?php if( in_array( 'Blue', get_field('materiale') ) ) {echo '<a href="' . get_field('link') . '" target="_blank" class="readmore"
    ...
    See more | Go to post
    Last edited by Rabbit; Aug 11 '13, 07:22 PM. Reason: Please use code tags when posting code.
No activity results to display
Show More
Working...