solved it using something like this
$fields = get_field_objects();
if( $fields ):
$fields = array_orderby($fields, 'menu_order', SORT_ASC);
foreach( $fields as $name => $value ):
[...]
function to order multidensional array:
function array_orderby()
{
$args = func_get_args();
$data = array_shift($args);
foreach ($args as $n => $field) {
if (is_string($field)) {
$tmp = array();
foreach ($data as $key => $row)
$tmp[$key] = $row[$field];
$args[$n] = $tmp;
}
}
$args[] = &$data;
call_user_func_array('array_multisort', $args);
return array_pop($args);
}
ok i solved this thank you so much. finally it worked for me like this to print all the values in subfields:
if($check['type'] == 'repeater'):
if( have_rows($name) ):
while ( have_rows($name) ) : $the_row = the_row();
foreach ($the_row as $key => $value) {
$content .= "$value </br>" ;
}
endwhile;
endif;
elseif($check['type'] == 'wysiwyg'):
$content .= $value;
else:
endif;
thanks for your help. I still don’t understand it. I tried removing the while loop and using your solution and I’m able to print all the keys and value but onyl from the first row of the array:
if($check['type'] == 'repeater'):
if( have_rows($name) ):
$values = get_field_object($name)? : [];
foreach ($values as $key => $value) {
$content .= "key: $key - value: $value </br>";
}
endif;
elseif($check['type'] == 'wysiwyg'):
$content .= $value;
else:
endif;
and what I’m actually trying to exactly do is this:
if( have_rows($name) ):
while ( have_rows($name) ) : the_row();
// write method to print subfields without knowing their names.
$content .= get_sub_field('effect_name') . "</br>";
$content .= get_sub_field('effect_magnitude') . "</br>";
$content .= get_sub_field('effect_description') . "</br>";
endwhile;
endif;
but without knowing the names ‘effect_name’, ‘effect_magnitude’ and ‘effect_description’
I fixed it. Fixes same problem with Table of content.
I just add the fields i want to be parsed by the plugins to wordpress’ the_content() in my template.
<?php
add_filter('the_content','prepend_this');
function prepend_this($content)
{
$content = get_field("some_field");
return $content;
}
?>
<?php the_content(); ?>
my site uses only ACF fields for content, so the_content() is always empty. Your results may vary.
If something’s not clear, ask away.
hey so i found this code:
function acf_apply_content_filter_for_api($value, $post_id, $field){
return str_replace( ']]>', ']]>', apply_filters( 'the_content', $value) );
}
function add_content_filter_ACF(){
if(!is_admin()){
remove_all_filters('acf/format_value/type=wysiwyg');
add_filter('acf/format_value/type=wysiwyg', 'acf_apply_content_filter_for_api', 10, 3);
}
}
add_action('init', 'add_content_filter_ACF');
and i was trying to subsitute
remove_all_filters('acf/format_value/type=wysiwyg');
for
remove_all_filters('acf/format_value/name=publication_content');
but the substitution doesnt work. can someone help me and tell me how should i modify the code? Footnotes are crucial to my website. thanks
PS oh, i see the thread is closed, should I start a new thread?
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.