最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Custom Fields displaying in single line

programmeradmin1浏览0评论

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 101
Add a comment  | 

2 Answers 2

Reset to default 0

Probably 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.

发布评论

评论列表(0)

  1. 暂无评论