Support

Account

Home Forums Front-end Issues uppercase

Solving

uppercase

  • hi
    after a lot of hard work, I found this option
    which displays the label but makes the contents of the field in uppercase
    how can i change the code just like Field Label to be uppercase and the content of the field to be written normally?
    thank you

    <?php
    
    $fields = get_field_objects();
    
    if( $fields )
    {
    	foreach( $fields as $field_name => $field )
    	{
    		echo '<div>';
    			echo '<h3>' . $field['label'] . '</h3>';
    			echo $field['value'];
    		echo '</div>';
    	}
    }
    
    ?>
  • I personally would do this using CSS

    
    // css
    .target.your.label {
      text-transform: uppercase;
    }
    

    You can do it in PHP by using strtoupper()

    
    <?php
    
    $fields = get_field_objects();
    
    if( $fields )
    {
    	foreach( $fields as $field_name => $field )
    	{
    		echo '<div>';
    			echo '<h3>' . strtoupper($field['label']) . '</h3>';
    			echo $field['value'];
    		echo '</div>';
    	}
    }
    
    ?>
    
  • for every label? I have 50-60 field
    and are we talking about label or field content? that I am interested in the contents of the field
    thank you

  • I don’t know why your site is showing the content of the field in upper case other than that’s the way it was entered. ACF does not alter the case of either the values or the labels from what is entered into the admin. If this is happening then you need to look at something else. Maybe there is already CSS in place that is doing this.

  • because of echo ‘<h3>’ . $field[‘label’] . ‘</h3>’;
    from the code

  • but I do not want to quit because I want the label to be capitalized, but the text of the field to be normal

  • <h3> does not automatcially set the text to upper case unless there is a CSS rule in your stylesheet that tells it to.

  • Nothing in the code you presented indicates why the content is being transformed to upper case and this has nothing to do with the code that you’ve posted.

    ACF does not do this transformation.

    This means that:

    1. The text entered into the field is upper case
    2. There is a CSS rule somewhere that is doing the transformation
  • surely 2. I did not check but …
    I’m sorry to have bothered you with such a trifle

    but the problem here is very important

    https://support.advancedcustomfields.com/forums/topic/gallery-array/
    is something simple I think, but I dont find solution

  • It’s not a bother, it’s why I’m here, to point people in the right direction.

  • And you are doing it in a great way…Thank you so much for helping people over here.Just love people over here

  • And you are doing it in a great way…Thank you so much for helping people over here.Just love people over here mybkexperience

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

The topic ‘uppercase’ is closed to new replies.