Hi, I’m trying to get the more tag for a WYSIWYG field to convert to a span like on a regular page:
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
is converted to this:
<span id="more-36"></span>
But the ACF WYSIWYG field, the more tag just returns as:
<!--more-->
I’ve tried
<?php
$value = get_field('about');
echo apply_filters('the_content',$value);
?>
but that doesn’t convert it to the span.
Hi @radirot
I’m not sure why it isn’t working, but you can always use acf/load_value and str_replace to change that tags automatically for WYSIWYG custom field. You can use this code to do it:
function my_acf_load_value( $value, $post_id, $field )
{
// run the_content filter on all textarea values
$value = apply_filters('the_content',$value);
$value = str_replace("<!--more-->", '<span id="more-'. $post_id .'"></span>', $value);
return $value;
}
add_filter('acf/load_value/type=wysiwyg', 'my_acf_load_value', 10, 3);
I hope this helps.