0
votes

I can't seem to display only the content I request. I am using the Advanced Custom Fields (ACF) plugin with my Wordpress site, and using a repeater field with a multiple select field for "departments \ job titles".

With the code below, I am looking to display only the content which has the value that equals what I select. Maybe I am looking at this wrong but the content displays whether the strpos is true or not.

<?php if (get_field('policy_links') ): ?>
   <center><h3><a name="All"></a>All Employees</h3></center>
    <hr>
    <ul class="bullets">
        <?php while (has_sub_field('policy_links')) : ?>
            <?php $jobtype = get_sub_field('who_is_this_for'); ?>
            <?php if (strpos ($jobtype, 'ma') !== false) { ?>                    
                <li><a href="<?php the_sub_field('link_to_the_document'); ?>">
                 <?php the_sub_field('display_name'); ?></a><span> -  <small>   
                 <?php the_sub_field('link_notes'); ?></small></span>
                 <?php the_sub_field('who_is_this_for'); ?></li>
            <?php } else { ?><p>fail </p>
            <?php }; // end of the loop. ?>
        <?php endwhile; // end of the loop. ?>
    </ul>
            <?php endif; ?>
2
Please provide an example of names, highlighting those that should have your if statement be true. - George

2 Answers

0
votes

Your if statement should be done like this:

<?php if(get_sub_field('who_is_this_for') == 'strpos') { ?><?php }?>

Where "strpos" is the value you select (if I follow correctly).

It would probably be beneficial to actually see your fields.

0
votes

I was on the right track. It turns out the ACF is converted to an array when multiple values are selected. I performed an implode to the variable then used the converted string performed the validation. thanks for the help