• Hi,
    I have question about custom field.
    If I have a custom value number is: 12345
    So I have code: <?php echo get_post_meta($post->ID, “number”, true); ?>
    But I want to select to display 123 (3 first characters in custom field “number”, so how can I display it.

    Thanks

Viewing 1 replies (of 1 total)
  • Thread Starter Liam

    (@rhinownam)

    I have an anwser for who find this problem:
    <?php
    $trim_length = 3; //desired length of text to display
    $custom_field = ‘my-custom-field-name’;
    $value = get_post_meta($post->ID, number, true);
    if ($value) {
    echo rtrim(substr($value,0,$trim_length));
    }
    ?>

Viewing 1 replies (of 1 total)
  • The topic ‘split the 3 first characters value in custom field’ is closed to new replies.