This is a 2 in 1 request attempt.
1. I’m trying to pull the values of a specific custom field named (status_value) located within custom posts generated by the subscribers and show them within the loop_posts page one after the other based on the condition that IF the user filled up the status_value field, display it, if not, don’t.
I took a look at the following codex link explaining the custom fields and my guess is that I will be using something similar to:
<?php $key="mykey"; echo get_post_meta($post->ID, $key, true); ?>
In my case, I tried:
<b>Status:</b> <span class="status_value"><?php echo get_post_meta($post->ID, 'status_alert', true); ?></span>
This works fine for pulling the custom field value, but I’m stuck with the static display of the wording “Status:” and I need it displayed IF the value is filled up or or else display none.
2. The second challenge is to limit the amount of characters of the outputed value of “status_value” given it will be displayed within a div of 480px width.
I found this thread and it seemed logical to combine it with the 1st step, but how to blend both functions?
- The topic ‘Display or Hide custom field if active and limit characters’ is closed to new replies.