title: test condition of advance custom field is true in WordPress
body: <p>i'm trying to test if a post has either of two conditions of a custom field. i'm using the plugin advanced custom types. i've created a field called visibility whereby the administrator can select whether a post of page is public or private. this will then display a custom message depending on whether the user is logged in and the condition of the field. However with my code below the condition is always returned as public even if the field is set to private on a post.</p>
  
  <pre><code>&lt;?
  $visibility = get_field('visibility');
  
  if($visibility='public'){ 
  
  
  get_template_part( 'content', 'single' ); 
  
  
  } else if ($visibility='private') { ?&gt;
  
  &lt;p&gt;You must be logged in to view this post&lt;/p&gt;
  
  &lt;?php } ?&gt;
  </code></pre>