wordpress 首页模板变量对应表

时间:2021-06-20 16:17:07

最近开始学习wp,这里做一些笔记。

首页模板,第一行为前台显示的html代码。第二行为 wp-content/themes/模板目录 下 head.php文件中。

其中我将变量名 html用绿色标记 php代码用红色标记

语言格式

<html lang="zh-CN">

<html <?php language_attributes(); ?>>

页面编码

<meta charset="UTF-8" />

<meta charset="<?php bloginfo( 'charset' ); ?>" />

页面标题

<title>谢寒博客 | 又一个WordPress站点</title>

<title> <?php wp_title( '|', true, 'right' ); ?> </title>

发布街口

<link rel="pingback" href="http://localhost/blog/xmlrpc.php" />

<link rel="pingback" href=" <?php bloginfo( 'pingback_url' ); ?> " />

目录地址:

<script src="http://localhost/blog/wp-content/themes/twentytwelve/js/html5.js" type="text/javascript"></script>

<script src=" <?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>

css和js地址

<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://localhost/blog/xmlrpc.php?rsd" />

<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://localhost/blog/wp-includes/wlwmanifest.xml" />

<meta name="generator" content="WordPress 3.6" />

<style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>

<style type="text/css" media="print">#wpadminbar { display:none; }</style>

<style type="text/css" media="screen">

html { margin-top: 28px !important; }

* html body { margin-top: 28px !important; }

</style>

<?php wp_head(); ?>

body class

<body class="home blog logged-in admin-bar no-customize-support custom-font-enabled single-author" >

<body <?php body_class(); ?> >

标题部分

<h1 class="site-title">

<a href="http://localhost/blog/"

title="站点标题" rel="home">

站点标题</a></h1>

<h1 class="site-title">

<a href=" <?php echo esc_url( home_url( '/' ) ); ?> "

title=" <?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?> " rel="home">

<?php bloginfo( 'name' ); ?> </a></h1>

副标题

<h2 class="site-description">又一个WordPress站点</h2>

<h2 class="site-description"> <?php bloginfo( 'description' ); ?> </h2>

菜单

<h3 class="menu-toggle">菜单</h3>

<h3 class="menu-toggle"> <?php _e( 'Menu', 'twentytwelve' ); ?></h3>

跳至内容

<a class="assistive-text" href="#content" title=" 跳至内容">跳至内容</a>

<a class="assistive-text" href="#content" title=" <?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to content', 'twentytwelve' ); ?> </a>

导航栏

<div class="nav-menu"><ul><li class="current_page_item"><a href="http://localhost/blog/" title="首页">首页</a></li><li class="page_item page-item-2"><a href="http://localhost/blog/?page_id=2">示例页面</a></li></ul></div>

<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>