Support

Account

Home Forums Front-end Issues Add a class to every paragraph created by textarea

Solving

Add a class to every paragraph created by textarea

  • Hello,

    How can I add a class to every single p created by textarea? It will be the same class but different per textarea field

  • Hello,

    in the settings of your field, you have a “class” option.
    you can define your class there, and then in CSS

    p.yourclass { yourcss; }

  • The class setting is only used in the admin and I thing that the question is about the front end of the site.

    The best choice for this is to wrap your field output in a div and use it to target the p’s in it.

    
    <div class="your-class-here"><?php the_field('your-field'); ?></div>
    

    <style>
    .your-class-here p {
    /* your styles here */
    }
    </style>

  • My solution:

    <?php echo str_replace('<p>', '<p class="yourclass">', get_field( 'yourfield' ) ); ?>

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Add a class to every paragraph created by textarea’ is closed to new replies.