Reputation: 117
I have this code and works fine:
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'colors', true);
I want delete characters ,
and insert <br />
with code like this:
echo str_replace(",", "<br />", get_post_meta($postid, 'colors', true));
But, how can I put both of codes correctly in PHP?
If I put this, it won't work:
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'colors', true);
echo str_replace(",", "<br />", get_post_meta($postid, 'colors', true));
Upvotes: 0
Views: 47
Reputation: 1277
Try this:
<?php
global $wp_query;
$postid = $wp_query->post->ID;
echo str_replace(',', '<br />', get_post_meta($postid, 'colors', true));
?>
Upvotes: 1