I want to create an if-else statement to wrap a title only if it has a link.
If has link wrap in a link if else just show title with no link.
I have a True False setup to show or hide the link field on the dashboard.
(See Link)
https://dl.dropboxusercontent.com/u/1476915/acf-arts.png
Current Code:
<div class="column1">
<?php if( have_rows('the_arts') ): ?>
<h3>The Arts</h3>
<ul>
<?php while( have_rows('the_arts') ): the_row(); ?>
<li><a href="<?php the_sub_field('work_link'); ?>"> <?php the_sub_field('work_title'); ?></a></li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
</div> <!--column1-->
Any help would be greatly appreciated!
<?php
if (get_sub_field('show_the_link')) {
?><a href="<?php the_sub_field('work_link'); ?>"> <?php the_sub_field('work_title'); ?></a><?php
} else {
the_sub_field('work_title');
}
?>
Thanks so much John!
How would I make sure the <li>
tag was till wrapped around the non-linked items?
my code was only to replace the part between the <li>
tags
<li><?php
if (get_sub_field('show_the_link')) {
?><a href="<?php the_sub_field('work_link'); ?>"> <?php the_sub_field('work_title'); ?></a><?php
} else {
the_sub_field('work_title');
}
?></li>