2011-04-01 104 views

回答

1

你不想要一个插件,而是一个页面试用版。

首先,在模板中,为您的两列编写HTML和CSS。一个非常基本的模板可能如下所示:

<?php get_header(); ?> 

<div id="column1"> 
</div> 

<div id="column2"> 
</div> 

<?php get_footer(); ?> 

现在您将为您的布局的每一列提供相应的帖子。而不是有一个WordPress循环显示你的帖子,你会在页面上有多个循环,每个列/区域一个循环。

<?php while (have_posts()) : the_post(); ?> 
... 
... 
<?php endwhile;?> 

例如,在您的博客中,您将在每一列中都有一个。

在每个循环之前,我们需要告诉WordPress要显示哪些帖子。我们添加一行代码,这将是这个样子:

<?php query_posts('cat=1&showposts=10'); ?> 

在这个例子中,它会拉在从1类10个职位。如果我想从两个类别显示帖子(我做我的博客),它会是这样的:

<?php query_posts('cat=1,2&showposts=10'); ?> 

如果你想展示的一切,但1类,使用方法:

<?php query_posts('cat=-1'); ?> 

你可以做很多事query_posts。

最后,您将在显示特定内容方面添加所需的任何内容。例如:

<div class="entry"> 
    <?php the_content(); ?> 
</div> 

完整的例子可能是这样的:

<?php get_header(); ?> 

<div id="column1"> 
<?php query_posts('cat=1'); ?> 
<?php while (have_posts()) : the_post(); ?> 
<h2 id="post-<?php the_ID(); ?>"> 
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> 
<?php the_title(); ?></a></h2> 
<small><?php the_time('F jS, Y') ?> by <?php the_author() ?></small> 
<div class="entry"> 
<?php the_content('Read the rest of this entry &raquo;'); ?> 
</div> 
<?php endwhile;?> 
</div> 

<div id="column2"> 
<?php query_posts('cat=2'); ?> 
<?php while (have_posts()) : the_post(); ?> 
<h2 id="post-<?php the_ID(); ?>"> 
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> 
<?php the_title(); ?></a></h2> 
<small><?php the_time('F jS, Y') ?> by <?php the_author() ?></small> 
<div class="entry"> 
<?php the_content('Read the rest of this entry &raquo;'); ?> 
</div> 
<?php endwhile;?> 
</div> 

<?php get_footer(); ?> 

退房http://codex.wordpress.org/Stepping_Into_Templateshttp://codex.wordpress.org/The_Loop_in_Action获取更多信息。