关于Wordpress(PHP)的自定义博客页面 - 分页
问题描述:
我试图在this page上显示自定义缩略图和标题的前5个帖子,我只需要显示接下来5个帖子的标题,然后显示分页。你可以看到我需要的一个例子by clicking here。 (请参阅左侧的帖子)关于Wordpress(PHP)的自定义博客页面 - 分页
以下是我在页面上使用的自定义模板。
<?php
get_header(); ?>
<div id="primary">
<div id="content" role="main">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts($args);
if(have_posts()) :?>
<?php twentyeleven_content_nav('nav-above');?>
<?php while (have_posts()) : the_post(); ?>
<div class="post-thumb-title">
<a href="<?php the_permalink() ?>"><?php the_post_thumbnail(array(632,305));?></a>
<p class="thumb-title2"><?php the_title(); ?></p>
<p class="news-date"><?php the_time('F jS, Y') ?></p>
<div id="post-excerpt">
<?php the_excerpt(); ?>
</div>
</div>
<?php endwhile; ?>
<?php twentyeleven_content_nav('nav-below'); ?>
<?php else : ?>
<article id="post-0" class="post no-results not-found">
<header class="entry-header">
<h1 class="entry-title"><?php _e('Nothing Found', 'twentyeleven'); ?></h1>
</header><!-- .entry-header -->
<div class="entry-content">
<p><?php _e('Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyeleven'); ?></p>
<?php get_search_form(); ?>
</div>
<?php endif; ?>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
感谢
答
你可以尝试这样的事情
<?php
// amount of posts shown with thumbnail
// post 6 .. pagesize (wp-admin > settings > reading) will be displayed as link only
$withThumb = 5;
while (have_posts()) : the_post();
if ($withThumb-- > 0) { ?>
<div class="post-thumb-title">
<a href="<?php the_permalink() ?>"><?php the_post_thumbnail(array(632,305));?></a>
<p class="thumb-title2"><?php the_title(); ?></p>
<p class="news-date"><?php the_time('F jS, Y') ?></p>
<div id="post-excerpt">
<?php the_excerpt(); ?>
</div>
</div>
<?php } else { ?>
<div class="post-title">
<p class="thumb-title2">
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
</p>
</div>
<?php } ?>
<?php endwhile; ?>
这是打破我的网页。没有运气。 –
可能,没有测试它,但得到了任何错误消息/警告? –
没有。只是一个空白的页面。我确定我正确地替换了我的代码,因为我检查了两次。 –