我有这个代码,工作正常:
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'colors', true);
我希望删除字符,
并使用以下代码插入<br />
:
echo str_replace(",", "<br />", get_post_meta($postid, 'colors', true));
但是,我怎样才能在PHP中正确地放置这两个代码?
如果我这样做,它将不起作用:
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));
答案 0 :(得分:1)
试试这个:
<?php
global $wp_query;
$postid = $wp_query->post->ID;
echo str_replace(',', '<br />', get_post_meta($postid, 'colors', true));
?>