我正在使用自定义字段向产品页面添加一些额外内容。因此,我通过函数钩住它。phpBut出于某种原因,在Wordpress后端编辑产品端时,它会在每个撇号前添加3个斜杠。示例:src="..."
将导致src=///"..///"
每次单击“保存”,都会创建3个新的斜杠。我尝试了stripslashes\\u deep()和stripslashes(),但没有成功,如您所见:
add_action(\'woocommerce_before_single_product\', \'headline_placeholder\');
function headline_placeholder () {
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, \'productheadline\', true);
wp_reset_query();
}
你知道是什么导致了这个问题吗?---- UPDATE ----我想我找到了一种方法,但它只减少了2个反斜杠,而不是全部3个:
function removeslashes($string)
{
$string=implode("",explode("\\\\",$string));
return stripslashes(trim($string));
}
add_action(\'woocommerce_before_single_product\', \'headline_placeholder\');
function headline_placeholder () {
global $wp_query;
$postid = $wp_query->post->ID;
$meta = get_post_meta($postid, \'productheadline\', true);
echo removeslashes($meta);
wp_reset_query();
}