I have custom fields to display in a post. But all of the custom fields are displaying in a single continuous line, while i want them in separate lines. I am not a coder. I tried <br>, <li>
but still no luck. I also searched in stack exchange and web for similar problem, but could not get answer. Please help.
Below is the Code i have in single.php after - while ( have_posts() ) : the_post();
$key_name = get_post_custom_values ($key = 'country'); echo 'Country : ', $key_name[0];
$key_name = get_post_custom_values ($key = 'status'); echo 'Status : ', $key_name[0];
The result in the post is as below:
Country : Saudi ArabiaStatus : Announced
I want it to appear it like the one below:
Country : Saudi Arabia
Status : Announced
I have custom fields to display in a post. But all of the custom fields are displaying in a single continuous line, while i want them in separate lines. I am not a coder. I tried <br>, <li>
but still no luck. I also searched in stack exchange and web for similar problem, but could not get answer. Please help.
Below is the Code i have in single.php after - while ( have_posts() ) : the_post();
$key_name = get_post_custom_values ($key = 'country'); echo 'Country : ', $key_name[0];
$key_name = get_post_custom_values ($key = 'status'); echo 'Status : ', $key_name[0];
The result in the post is as below:
Country : Saudi ArabiaStatus : Announced
I want it to appear it like the one below:
Country : Saudi Arabia
Status : Announced
Share Improve this question asked Apr 29, 2020 at 14:04 Kishore ChandraKishore Chandra 1012 Answers
Reset to default 0Probably not the best solution, but why don't you try the following:
while ( have_posts() ) : the_post(); ?>
<div><?php $key_name = get_post_custom_values ($key = 'country'); echo 'Country : ', $key_name[0]; ?> </div>
<div><?php $key_name = get_post_custom_values ($key = 'status'); echo 'Status : ', $key_name[0]; ?> </div>
I found a solution based on the answer provided by user4379653 here https://stackoverflow/questions/27636676/php-line-break-not-working
I used <br />
in echo from the second custom field, as the first field would not require.
$key_name = get_post_custom_values ($key = 'status'); echo '<br />Status : ', $key_name[0];
Thanks to Ivo for trying to help.