Support

Account

Home Forums General Issues How can I can HTML code to appear as code in the field instructions?

Solving

How can I can HTML code to appear as code in the field instructions?

  • I’m trying to output this in an instruction field for a text field:

    Put freelancer promotions here. Use this shortcode to display it in your article:
    <div class=”author-promo”>[acf field="author_promo"]</div>

    I have tried this:

    <div class="author-promo">[acf field="author_promo"]</div>

    But the divs still don’t show.

  • If you want to show html then you’ll need to put the HTML entities into the label. Either that or filter the label when loading the field. Something like this should work

    
    add_filter('acf/load_field/name=your-field-name', 'acf_label_htmlentities');
    function acf_label_htmlentities($field) {
     $field['label'] = htmleneities($field['label']);
     return $field;
    }
    
  • Not sure what I’m doing wrong but I keep getting:

    Fatal error: Call to undefined function htmleneities()

        add_filter('acf/load_field/name=author_promo', 'acf_label_htmlentities');
        function acf_label_htmlentities($field) {
            $field['label'] = htmleneities($field['label']);
            return $field;
        }
  • because I can’t spell

    
    add_filter('acf/load_field/name=author_promo', 'acf_label_htmlentities');
        function acf_label_htmlentities($field) {
            $field['label'] = htmlentities($field['label']);
            return $field;
        }
    
Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘How can I can HTML code to appear as code in the field instructions?’ is closed to new replies.