Hi. Same problem was with my code.
My solution is in plugin update (in my case update ACF from 5.8.4 to 5.8.7).
option page should be last in select
I don’t understand what you want to do )))) and why you try use %1$s, %2$s, %3$s
Perhaps this is not the case. The first message shows that you created a field for a specific post. If you are trying to access this field from another template, then you need to use additionally the id of this post.
in post
<h4>Somme text: <?php the_field('custom_filed'); ?></h4>
outside this post
<h4>Somme text: <?php the_field('custom_filed', $post_id); ?></h4>
e.g.
<h4>Somme text: <?php the_field('custom_filed', 10); ?></h4>
where 10 is ID of post
try change order of commands. This is my working example:
function enqueue_scripts()
$params = array ( 'someparam' => get_field('field_name', 'options') );
wp_register_script('scripts', 'js/scripts.js', array('jquery'), false, false);
wp_localize_script( 'scripts', 'params', $params );
wp_enqueue_script('scripts');
}
add_action('wp_enqueue_scripts', 'enqueue_scripts');
I’m not a telepath and I do not see from here how you inserted the code. Take at least a screenshot
put it in function.php
1. register option page
if (function_exists('acf_add_options_page')) {
acf_add_options_page(array(
'page_title' => 'Site Options',
'menu_title' => 'Site Options',
'menu_slug' => 'acf-options',
'position' => '103.3',
'capability' => 'edit_posts',
'redirect' => false,
));
}
2. In WordPress Admin go to “Custom fielsd” menu? create new Field Group and assosiate it with your option page https://gyazo.com/13f3a19a98794439fd2e5b0228180587
3. In template (index.php or category.php) use the_field('field-name', 'options');
to show your custom field
Perhaps it is too late , but still write his solution
<?php if (have_rows('repeater_field')) { ?>
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<?php
$faq_a = 0; //add counter for targeting first acccordion element
while (have_rows('repeater_field')) {
the_row();
?>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading_<?php echo $faq_a ?>">
<h4 class="panel-title">
<a class="<?php if ($faq_a != 0) echo 'collapsed' ?>" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse_<?php echo $faq_a ?>" aria-expanded="<?php
if ($faq_a == 0) {
echo 'true';
} else {
echo 'false';
};
?>" aria-controls="collapse_<?php echo $faq_a ?>">
<?php the_sub_field('repeater_subfield_1'); ?>
</a>
</h4>
</div>
<div id="collapse_<?php echo $faq_a ?>" class="panel-collapse collapse <?php if ($faq_a == 0) echo 'in' ?>" role="tabpanel" aria-labelledby="heading_<?php echo $faq_a ?>">
<div class="panel-body italic">
<?php the_sub_field('repeater_subfield_2'); ?>
</div>
</div>
</div>
<?php
$faq_a++;
}
?>
</div>
<?php } ?>
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.