Home › Forums › General Issues › Can't get values while creating loop for shortcode › Reply To: Can't get values while creating loop for shortcode
Ok, i solved my problem. Seems like those two directives was not even required(i can use subfields as arrays).
The problem was with NAMES of those fields! I forgot _ symbol in between.
So the code at the end is:
function ssf(){
global $post;
$post_id = $post->id;
$rep = get_field('sourcepage', $post_id);
if ($rep && is_array($rep)) {
foreach ($rep as $item) {
$output .= '<span class="set blue">
<a class="btn-pbt pri ico" href="'.$item['link_przycisku'].'">'.$item['nazwa_przycisku'].'</a>
</span>';
}
}
return $output;
}
add_shortcode('guzik', 'ssf');
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.