我创建了一个简短的代码,在两个不同的页面中显示一些内容。
两个网站都有不同的样式来显示短代码的相同内容。
但是,条件标签无法正常工作。
这里是代码:
function comunicacionpdf_sc($atts, $content = null) {
extract(shortcode_atts(array("url" => 'http://www.example.com/file.pdf'), $atts));
if (is_page('comunicaciones')) {
return 'test';
//$output .= '<h6><a href="'.$url.'" target="_blank">Descargar PDF</a></h6>';
} else {
//$output .= '<div class="cd_comunicacionespdf"><a href="'.$url.'" target="_blank">Descargar Aquí</a></div>';
return 'no-test';
}
}
add_shortcode('comunicacionpdf', 'comunicacionpdf_sc');
请忽略实际上会在前端查看的注释输出。
从那以后,非常感谢你的帮助