如何向php函数添加div元素
我已经在wordpress themes functions.php文件中添加了可用的php代码 一切都很顺利。我所要做的就是添加一个div类来设置输出的样式 我不知道该怎么做,非常感谢您的建议。我试着加上如何向php函数添加div元素,php,html,Php,Html,我已经在wordpress themes functions.php文件中添加了可用的php代码 一切都很顺利。我所要做的就是添加一个div类来设置输出的样式 我不知道该怎么做,非常感谢您的建议。我试着加上 <div class="custom"> echo get_option ('woo_customtext'</div>); 使用 if(is_single()){ 回显“”。获取选项('woo_customtext'); } 或 if(is_singl
<div class="custom"> echo get_option ('woo_customtext'</div>);
使用
if(is_single()){
回显“”。获取选项('woo_customtext');
}
或
if(is_single()){
?>
echo get_选项('woo_customtext'))
与有效语法相差甚远。发布错误可能会很有用。你似乎也没有正确响应。标签在哪里?这有点乱。这是在Wordpress中完成的吗?是的,我实际上从woo themes那里得到了建议!M Miller帮我找到了我想要的解决方案。谢谢你Miller,谢谢你的支持和advice.echo''get_option('woo_customtext')''工作得很好。我明白您现在将其打印为字符串的意思。再次感谢您!
add_action( 'woo_post_inside_before', 'woo_add_custom' );
function woo_add_custom() {
if (is_single()){
echo get_option ('woo_customtext');
}
}
if (is_single()) {
echo '<div class="custom">'.get_option('woo_customtext').'</div>';
}
if (is_single()) {
?>
<div class="single"><?php echo get_option('woo_customtext'); ?></div>
<?php
}