0

我有这段代码并且工作正常:

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));
4

1 回答 1

1

尝试这个:

<?php 
global $wp_query; 
$postid = $wp_query->post->ID; 
echo str_replace(',', '<br />', get_post_meta($postid, 'colors', true));
?>
于 2013-09-29T15:55:54.500 回答