2023-06-11 / 777阅
wp_head()
示例代码:
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><?php wp_title(); ?></title>
<?php wp_head(); ?>
</head>
wp_footer()
示例代码:
<body>
<!-- 页面内容 -->
<?php wp_footer(); ?>
</body>
get_template_directory_uri()
示例代码:
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/style.css">
the_post_thumbnail()
示例代码:
<?php if(has_post_thumbnail()): ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php the_post_thumbnail('large', array('class' => 'thumbnail')); ?>
</a>
<?php endif; ?>
register_nav_menus()
示例代码:
function theme_nav_menus() {
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'theme' ),
'footer' => __( 'Footer Menu', 'theme' )
) );
}
add_action( 'after_setup_theme', 'theme_nav_menus' );
dynamic_sidebar()
示例代码:
<aside>
<?php if( is_active_sidebar( 'sidebar' ) ) : ?>
<?php dynamic_sidebar( 'sidebar' ); ?>
<?php endif; ?>
</aside>
get_template_part()
示例代码:
<?php get_template_part( 'content', 'single' ); ?>
comments_template()
示例代码:
<?php if ( comments_open() || get_comments_number() ) :
comments_template();
endif; ?>
esc_attr__()
示例代码:
<div class="<?php echo esc_attr__( 'my-class' ); ?>">
<!-- 内容 -->
</div>
wp_enqueue_script()
示例代码:
function theme_scripts() {
wp_enqueue_script( 'custom-script', get_template_directory_uri() . '/js/custom.js', array('jquery'), '1.0', true );
}
add_action( 'wp_enqueue_scripts', 'theme_scripts' );
阅读文章或者观看视频过程中有任何问题,请下方留言或者联系我Q248758228