我在模板文件中有一些代码。当我从后端的post面板(HTML选项卡)将其粘贴为post,并将其作为自定义循环检索时,代码输出不好。
有什么建议吗?
将其添加为帖子:
<?php
/**
* Template Name: Lyrics Page
* @package WordPress
* @subpackage Prominent
* @since Prominent 1.0
*/
get_header(); ?>
<div id="tagline">
<div class="container">
<?php // Run main loop (The Loop). ?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div class="content0">
</div>
<?php endwhile; ?>
</div><!-- .container -->
</div><!-- #content-bottom -->
<div id="content">
<div class="container">
<div id="mainbar">
<div id="accordions-top">
<?php $custom_posts = new WP_Query(); ?>
<?php $custom_posts->query(\'category_name=Lyrics\'); ?>
<?php while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
</div>
</div><!-- #mainbar -->
<?php get_sidebar(); ?>
</div><!-- .container -->
</div><!-- #content-bottom -->
<?php get_footer(); ?>
直接在文件上:
<?php
/**
* Template Name: Lyrics Page
* @package WordPress
* @subpackage Prominent
* @since Prominent 1.0
*/
get_header(); ?>
<div id="tagline">
<div class="container">
<?php // Run main loop (The Loop). ?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div class="content0">
<?php the_content(); ?>
</div>
<?php endwhile; ?>
</div><!-- .container -->
</div><!-- #content-bottom -->
<div id="content">
<div class="container">
<div id="mainbar">
<div id="accordions-top">
<div class="basic" style="float:left; margin-left: 2em;" id="list1e">
<a>There is one obvious advantage:</a>
<div>
<p>
You\'ve seen it coming!<br/>
Buy now and get nothing for free!<br/>
Well, at least no free beer. Perhaps a bear,<br/>
if you can afford it.
</p>
</div>
<a>Now that you\'ve got...</a>
<div>
<p>
your bear, you have to admit it!<br/>
No, we aren\'t selling bears.
</p>
</div>
<a>Rent one bear, ...</a>
<div>
<p>
get two for three beer.
</p>
<p>
And now, for something completely different.<br/>
And now, for something completely different.<br/>
And now, for something completely different.<br/>
And now, for something completely different.<br/>
And now, for something completely different.<br/>
And now, for something completely different.<br/>
And now, for something completely different.<br/>
And now, for something completely different.<br/>
Period.
</p>
</div>
</div>
</div>
</div><!-- #mainbar -->
<?php get_sidebar(); ?>
</div><!-- .container -->
</div><!-- #content-bottom -->
<?php get_footer(); ?>
通过管理面板添加帖子时的输出:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 11 February 2007), see www.w3.org" />
<title></title>
</head>
<body>
<div id="content">
<div class="container">
<div id="mainbar">
<div id="accordions-top">
<div class="basic" style="float:left; margin-left: 2em;" id="list1e">
<a>There is one obvious advantage:</a>
<div>
<p>You’ve seen it coming!<br />
<br />
Buy now and get nothing for free!<br /></p>
<p>Well, at least no free beer. Perhaps a bear,<br />
<br />
if you can afford it.</p>
</div>
<p><a>Now that you’ve got…</a></p>
<div>
<p>your bear, you have to admit it!<br /></p>
<p>No, we aren’t selling bears.</p>
</div>
<p><a>Rent one bear, …</a></p>
<div>
<p>get two for three beer.</p>
<p>And now, for something completely different.<br />
<br />
And now, for something completely different.<br />
<br />
And now, for something completely different.<br />
<br />
And now, for something completely different.<br />
<br />
And now, for something completely different.<br />
<br />
And now, for something completely different.<br /></p>
<p>And now, for something completely different.<br />
<br />
And now, for something completely different.<br />
<br />
Period.</p>
</div>
</div>
</div>
</div><!-- #mainbar ==ý-->
</div>
</div>
</body>
</html>