Home › Forums › Add-ons › Flexible Content Field › Show all the flexible row labels used on a page? › Reply To: Show all the flexible row labels used on a page?
I used this to make it work:
<?php if (have_rows("content_builder")) {
$i = 0; ?>
<section class="second-nav" id="second-nav">
<div class="container">
<div class="second-nav__menu" id="second-nav__menu">
<?php while (have_rows("content_builder")) {
the_row();
$i++;
if ($i != 1):
$flexField = get_row_layout();
$flexField = str_replace("_", "-", $flexField);
echo "<a href='#" . $flexField . "'>";
if ($flexField == "neighbourhood-overview") {
echo "Overview";
} elseif ($flexField == "neighbourhood-map") {
echo "What's Around";
} elseif ($flexField == "neighbourhood-stories") {
echo "Tenant Stories";
} elseif ($flexField == "show-other-properties") {
echo "Our Properties";
} elseif ($flexField == "other-neighbourhoods") {
echo "Our Neighbourhoods";
} else {
$flexField = str_replace(
["_", "-"],
" ",
$flexField,
);
echo ucwords($flexField);
}
echo "</a>";
?>
<?php
endif;
}
}
}?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.