【发布时间】:2015-06-16 03:46:30
【问题描述】:
我是 WordPress 新手,在创建 WordPress 主题时遇到问题。
我创建了一个简单的模板(我的第一个模板),在教程中我读到我应该剪切所有标题内容并将其粘贴到header.php 文件中。
我这样做了,并将所有标题从<!Doctype html> 粘贴到header.php 中的</head>,当我使用get_header() 包含标题时,WordPress 在正文中的<div id="header" role="banner"> 中添加一个链接并向我展示。
我不需要那个链接和 div,如何摆脱它?
这是我的代码:
index.php:
<?php
get_header();
?>
<div id="extra-content">
<div id="extra-left-div">
<h3>Posts</h3>
<?php if(have_posts()): ?>
<?php while ( have_posts() ):the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php endwhile; ?>
<?php endif; ?>
</div>
<div id="extra-tag-div">
<h3>Tags</h3>
<?php the_tags('',''); ?>
</div>
<div id="extra-category-div">
<h3>Categories</h3>
<?php wp_list_categories('title_li=&hierarchical=0&depth=1&title_li=');?>
</div>
</div>
<div id="full-div">
<div id="logo">
<h1><?php bloginfo('name'); ?></h1>
</div>
<?php if ( have_posts() ) : ?>
<ul id="main-content">
<?php while ( have_posts() ) : the_post(); ?>
<li class="post" id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink() ?>"><h2 class="post-title"><?php the_title(); ?></h2></a>
<div class="summery-d"><?php the_excerpt(); ?></div>
<div class="post-meta">
<time> <?php the_date(); ?></time>
</div>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
<?php
get_footer();
?>
header.php
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?>">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/first.js"></script>
<title><?php
global $page, $paged;
wp_title( '|', true, 'right' );
bloginfo( 'name' );
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
echo " | $site_description";
if ( $paged >= 2 || $page >= 2 )
echo ' | ' . sprintf( __( 'Page %s', 'mytheme' ), max( $paged, $page ) );
?></title>
<meta name="description" content="<?php bloginfo('description'); ?>">
<link rel="stylesheet" media="screen" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" />
<?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
<link rel="alternate" type="appliction/rss+xml" href="<?php bloginfo('rss2_url'); ?>" title="<?php printf(__( 'آخرین مطالب %s', 'mytheme' ), wp_specialchars( get_bloginfo('name'), 1 ) ); ?>" />
<link rel="alternate" type="appliction/rss+xml" href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php printf(__( 'آخرین نظرات %s', 'mytheme' ), wp_specialchars( get_bloginfo('name'), 1 ) ); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
</head>
<body <?php body_class(); ?>>
<div class="behind" id="b-1">
</div>
<div class="behind" id="b-2">
</div>
<div class="behind" id="b-3">
</div>
<div class="behind" id="b-4">
</div>
<div class="behind" id="b-5">
</div>
<div class="behind" id="b-6">
</div>
<div class="behind" id="b-7">
</div>
<a id="menu-a" href="javascript:void(0);">
</a>
带有.behind类和#menu-a的div和其他一些元素不在源中(只需按ctrl+u),并添加了一个我不需要的链接
<div id="header" role="banner">
<div id="headerimg">
<h1><a href="http://balit.ir/blog/">Mohammad Kermani</a></h1>
<div class="description"></div>
</div>
</div>
<hr />
我正在处理this website
【问题讨论】:
标签: php wordpress templates wordpress-theming