我使用:get\\u theme\\u mod以以下格式显示来自主题定制器的各种信息:
<a href=" <?php get_theme_mod( $name, $default ) ?> ">This is the link</a>
如果特定的customizer字段为空,我想隐藏整行。我可以围绕锚点做些什么来实现这一点?
我使用:get\\u theme\\u mod以以下格式显示来自主题定制器的各种信息:
<a href=" <?php get_theme_mod( $name, $default ) ?> ">This is the link</a>
如果特定的customizer字段为空,我想隐藏整行。我可以围绕锚点做些什么来实现这一点?
$value = get_theme_mod( $name, $default );
if ($value !== $default) {
?>
<a href=" <?php echo $value; ?> ">This is the link</a>
<?php
}
正在查找显示默认文本以代替自定义程序集标题的答案。以一种有趣的迂回方式,@Otto的帖子给了我一个检查空字符串的想法。
<?php if( get_theme_mod( \'tcx_portfolio_intro\') == \'\' ) : ?>
<div class="intro">
<h2><?php echo (\'nothing here yet\'); ?></h2>
</div>
<?php endif; ?>
无论customizer设置中的默认值如何,都可以将主题修改值与空字符串进行比较:
<?php
$link = get_theme_mod( $name );
if ($link !== \'\' ) {
?>
<a href="<?php echo $link; ?> ">This is the link</a>
<?php
}
?>
我试图用代码在WordPress附件页(image.php)中的循环外显示自定义字段,它不返回任何内容。这是我用来显示自定义字段的代码:<?php global $wp_query; $postid = $wp_query->post->ID; echo get_post_meta($postid, \'my-custom-field\', true); ?> 我正试图在附件页toowith中显示父帖子idget_the_id 并使用此代码