1. 主页
  2. 文档
  3. WordPress函数
  4. get_theme_mod

get_theme_mod

原文:https://developer.wordpress.org/reference/functions/get_theme_mod/

get_theme_mod 获取主题的自定义信息

用法:

<?php get_theme_mod( $name, $default ); ?>

参数:

  • $name (string) (必填) Theme modification name. 默认值: None
  • $default (boolean|string) (可选) 默认值: false
  • 返回值: (string)

举例: 获取自定义背景

.footer {
     border-top: solid 1px #<?php echo get_theme_mod( 'background_color' ); ?>;
}

相关函数:

get_theme_mods() 获取所有主题可自定义的值

举例:

<?php if ( get_theme_mod( 'show_main_content', 1 ) ) : ?>

说明:

这个是自定义的????

举例:

<?php echo wp_kses_post( get_theme_mod( 'footer_text', '<a href="https://bootstrap-wp.com/">Bootstrap 4 WordPress Theme</a> <span class="sep"> | </span> Theme Name: WP Bootstrap 4.' ) ); ?>

说明:自定义的。

举例:

get_theme_mod( 'sticky_header', 0 )//置顶
get_theme_mod( 'header_within_container', 0 )//自定义的吧
get_theme_mod( 'show_site_description', 1 )
get_theme_mod( 'header_within_container', 0 )

说明:“ 置顶 ”

这篇文章对您有用吗?

我们要如何帮助您?