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?
@hube2
Here’s what I used to grab the fields.
I had to run the loop outside the main flex loop or else it caused timeout errors.
I also removed the first row of the loop since it was a True/False for checking if the nav should be present on the page.
Since the “get_row_layout()” only grabs the slug of the row, I had to manually change some of the title, but then made it just work for any others that may show up.
<?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.