Home Forums General Issues Filtering Content in ACF WYSIWYG Fields


Filtering Content in ACF WYSIWYG Fields

  • I’m trying to create filters that take the list tags UL and LI (if there are any) and apply classes to them. This would apply to any and every ACF WYSIWYG field that exists on the site.

    In my functions.php file I have added

    function my_add_ul_class_on_insert( $content ) {
        $pattern ="<ul>";
        $replacement = '<ul class="list-simple">';
        $content = preg_replace($pattern, $replacement, $content);
        return $content;
    add_filter('acf_the_content', 'my_add_ul_class_on_insert');
    function my_add_li_class_on_insert( $content ) {
        $pattern ="<li>";
        $replacement = '<li class="list-item">';
        $content = preg_replace($pattern, $replacement, $content);
        return $content;
    add_filter('acf_the_content', 'my_add_li_class_on_insert');

    But it doesn’t seem to work. What am I missing?

Viewing 1 post (of 1 total)

The topic ‘Filtering Content in ACF WYSIWYG Fields’ is closed to new replies.