Support

Account

Home Forums General Issues Get a non-formatting value from a sub field

Solved

Get a non-formatting value from a sub field

  • Hi!
    I’m trying to get a non-formatting value from a repeteter sub field.
    I’ve seen here that the second parameter can do it:
    https://www.advancedcustomfields.com/resources/get_sub_field/
    <?php get_sub_field($sub_field_name, $format_value); ?>
    But it doesn’t work on my code:

    <?php if( have_rows('descriptions') ): ?>
    	<?php while( have_rows('descriptions') ): the_row(); 
    		// vars
    		$titre = get_sub_field('titre_de_la_description');
    		$slug_field = get_sub_field('titre_de_la_description', false);
    		?>
    		<li><a href="#<?php echo $slug_field; ?>"><?php echo $titre; ?></a></li>
    	<?php endwhile; ?>
    <?php endif; ?>

    Is that a bug or am I doing something rong?

    Thanks in advance!

  • Whats in your input field, and what are you getting as a result?

  • It is a text field, and I get as a result the formatting text field (with accents, caps and spaces).

  • Unformulated does not refer to text formatting. For most fields that store simple text values (all of the basic fields) there is no difference between formatted and formatted. Unformatted in the ACF sense means that the value is returned exactly as it is stored in the database. For example, shortcodes and other filters will not be run on a WYSIWYG field, or a relationship field will return an array of post IDs instead of returning post objects. With a text field, the value you see is what is stored in the DB.

  • Okay, I get it. Sorry I misunderstood the doc -_-
    Could be great to get the field’s slug within the loop 🙂

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

The topic ‘Get a non-formatting value from a sub field’ is closed to new replies.