以下是WordPress牵引主题的PHP代码。我想在首页上显示的每个帖子/页面上显示我的关键字和描述。我该怎么做呢?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php if ( is_front_page() ) : ?>
<title><?php bloginfo( 'name' ); ?></title>
<meta name="description" content="<?php if ( is_single() ) {
single_post_title('', true);
} else {
bloginfo('name'); echo " - "; bloginfo('description');
}
?>" />
<meta name="keywords" content="mediafire, free movies, download movies, movies
mediafire, online movies, download mediafire movies, movies online, hindi movies, bollywood movies, english movies, small movies, high quality, small size, free
download, download, download links" />
<meta http-equiv="author" content="M.Naeem Riaz" />
<?php elseif ( is_404() ) : ?>
<title><?php _e( 'Page Not Found |', 'traction' ); ?> | <?php bloginfo( 'name' );
?></title>
<?php elseif ( is_search() ) : ?>
<title><?php printf(__ ("Search results for '%s'", "traction"), attribute_escape(get_search_query())); ?> | <?php bloginfo( 'name' ); ?></title>
<?php else : ?>
<title><?php wp_title($sep = '' ); ?> | <?php bloginfo( 'name' );?></title>
<?php endif; ?>
<!-- Basic Meta Data -->
<meta name="Copyright" content="Design is copyright <?php echo date( 'Y' ); ?> The
Theme Foundry" />
<meta http-equiv="imagetoolbar" content="no" />
<meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>;
charset=<?php bloginfo( 'charset' ); ?>" />
<?php if ((is_single() || is_category() || is_page() || is_home()) && (!is_paged())) :
else : ?>
<meta name="robots" content="noindex, follow" />
<?php endif; ?>
<!-- Favicon -->
<link rel="shortcut icon" href="<?php bloginfo( 'stylesheet_directory' ); ?>/images
/favicon.ico" />
<!--Stylesheets-->
<?php if ( ($traction->colorScheme() != 'default' ) ) { ?>
<link href="<?php bloginfo( 'stylesheet_directory' ); ?>/stylesheets/<?php
echo $traction->colorScheme(); ?>.css" type="text/css" media="screen" rel="stylesheet"
/>
<?php } ?>
<link href="<?php bloginfo( 'stylesheet_url' ); ?>" type="text/css" media="screen"
rel="stylesheet" />
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" media="screen" href="<?php
bloginfo( 'template_url' ); ?>/stylesheets/ie.css" />
<![endif]-->
<!--WordPress-->
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo( 'name' );
?> RSS Feed" href="<?php bloginfo( 'rss2_url' ); ?>" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<!--WP Hooks-->
<?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
<?php wp_enqueue_script( 'jquery' ); ?>
<?php wp_head(); ?>
<!--Scripts-->
<script type="text/javascript" src="<?php bloginfo( 'template_url' );
?>/javascripts/traction.js"></script>
<?php if ( is_front_page() && ($traction->sliderState() != '' ) ) { ?>
<!--Slider-->
<?php
$autoStart = 0;
$slidespeed = 300;
$fadespeed = 200;
if ($traction->sliderSpeed() != '' ) $slidespeed =
$traction->sliderSpeed();
if ($traction->sliderFade() != '' ) $fadespeed =
$traction->sliderFade();
if ($traction->sliderStart() == 'true' ) $autoStart =
$traction->sliderDelay(); else $autoStart = 0;
?>
<script type="text/javascript" charset="utf-8">
jQuery(function(){
jQuery("#feature").loopedSlider({
containerClick: false, autoStart: <?php echo $autoStart; ?>, slidespeed: <?php echo $slidespeed; ?>, fadespeed: <?php echo $fadespeed; ?>, autoHeight: 1
});
});
</script>
<?php } ?>
</head>
<body <?php body_class($traction->colorScheme()); ?>>
<div class="skip-content"><a href="#content"><?php _e( 'Skip to content', 'traction' ); ?></a></div>
<div id="pg-nav-bg">
<div class="wrapper clear">
<div id="pg-nav">
<ul class="nav">
<?php if ($traction->hideHome() !== 'true' ) : ?>
<li class="page_item <?php if
(is_front_page()) echo( 'current_page_item' );?>"><a href="<?php bloginfo( 'url' );
?>"><?php _e( 'Home', 'traction' ); ?></a></li>
<?php endif; ?>
<?php if ($traction->hidePages() !== 'true' ) : ?>
<?php wp_list_pages( 'title_li=&exclude='.
$traction->excludedPages()); ?>
<?php endif; ?>
</ul>
</div><!--end pg-nav-->
</div><!--end wrapper-->
</div><!--end page-navigation-bg-->
<div class="wrapper big">
<div id="header" class="clear">
<?php if ($traction->logoState() == 'true' ) : ?>
<div class="logo logo-img">
<a href="<?php bloginfo( 'url' ); ?>"><img
src="<?php bloginfo( 'stylesheet_directory' ); ?>/images/<?php echo
$traction->logoName(); ?>" alt="<?php if ($traction->logoAlt() !== '' ) echo
$traction->logoAlt(); else echo bloginfo( 'name' ); ?>"/></a>
<?php if ($traction->logoTagline() == 'true' ) { ?>
<div id="description">
<?php bloginfo( 'description' ); ?>
</div><!--end description-->
<?php } ?>
</div><!--end logo-->
<?php else : ?>
<div class="logo">
<?php if (is_home()) echo( '<h1 id="title">' );
else echo( '<div id="title">' );?><a href="<?php bloginfo( 'url' ); ?>"><?php
bloginfo( 'name' ); ?></a><?php if (is_home()) echo( '</h1>' ); else echo( '</div>'
);?>
<div id="description">
<?php bloginfo( 'description' ); ?>
</div><!--end description-->
</div><!--end logo-->
<?php endif; ?>
<?php if ($traction->bannerState() != '' ) { ?>
<div class="banner">
<a href="<?php if ($traction->bannerUrl() != '' )
echo $traction->bannerUrl(); else echo "#"; ?>"><img class="alignleft" src="<?php
bloginfo( 'stylesheet_directory' ); ?>/images/ads/<?php if ($traction->bannerImage() !=
'' ) echo $traction->bannerImage(); else echo "468_ad.png"; ?>" width="468"
height="60" alt="<?php if ($traction->bannerAlt() != '' ) echo $traction->bannerAlt();
else echo bloginfo( 'name' ); ?>" /></a>
</div>
<?php } ?>
<div id="cat-nav" class="clear">
<ul class="nav">
<?php if ($traction->hideCategories() != 'true' )
: ?>
<?php wp_list_categories( 'title_li=&
exclude=' . $traction->excludedCategories()); ?>
<?php endif; ?>
</ul>
</div><!--end cat-nav-->
</div><!--end header-->
<?php if (($traction->sliderState() != '' ) && is_front_page() &&
!is_paged() ) { ?>
<?php if (is_file(STYLESHEETPATH . '/featured.php' ))
include(STYLESHEETPATH . '/featured.php' ); else include(TEMPLATEPATH . '/featured.php'
); ?>
<?php } ?>
#1
如果你想要每个帖子/页面的元标记, 只需取出元数据作为全局条件is_front_page的描述和关键字。你与metatag有关的head部分代码如下(查看每种类型metatag的注释):
<!-- Title -->
<?php if ( is_front_page() ) : ?>
<title><?php bloginfo( 'name' ); ?></title>
<?php elseif ( is_404() ) : ?>
<title><?php _e( 'Page Not Found |', 'traction' ); ?> | <?php bloginfo( 'name' );
?></title>
<?php elseif ( is_search() ) : ?>
<title><?php printf(__ ("Search results for '%s'", "traction"), attribute_escape(get_search_query())); ?> | <?php bloginfo( 'name' ); ?></title>
<?php else : ?>
<title><?php wp_title($sep = '' ); ?> | <?php bloginfo( 'name' );?></title>
<?php endif; ?>
<!-- Description / Keywords -->
<meta name="description" content="<?php if ( is_single() ) {
single_post_title('', true);
} else {
bloginfo('name'); echo " - "; bloginfo('description');
}
?>" />
<meta name="keywords" content="mediafire, free movies, download movies, movies
mediafire, online movies, download mediafire movies, movies online, hindi movies, bollywood movies, english movies, small movies, high quality, small size, free
download, download, download links" />
<meta http-equiv="author" content="M.Naeem Riaz" />
<!-- Basic Meta Data -->
<meta name="Copyright" content="Design is copyright <?php echo date( 'Y' ); ?> The
Theme Foundry" />
<meta http-equiv="imagetoolbar" content="no" />
<meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>;
charset=<?php bloginfo( 'charset' ); ?>" />
<?php if ((is_single() || is_category() || is_page() || is_home()) && (!is_paged())) :
else : ?>
<meta name="robots" content="noindex, follow" />
评论前必须登录!
注册