【问题标题】:Display Post image on the Custom Page Template with Pagination在带有分页的自定义页面模板上显示帖子图像
【发布时间】:2013-09-06 19:21:14
【问题描述】:

我的页面模板有这个代码。

这就是我现在拥有的:http://www.ohright.com/emoticons/

如何更改它,以便它可以以每页 20 张图片的形式显示我所有的帖子图片,并在下方分页?

<?php
/*
Template Name: emoticons-page
*/
get_header(); ?>

<div id="content">
<div id="main">
<?php query_posts('cat=44'.get_the_title().'&post_status=publish,future');?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<p><?php the_content(); ?>
<?php endwhile; else: endif; ?>
</div>
</div>

<?php get_footer(); ?>

【问题讨论】:

  • 你可以使用'posts_per_page' =&gt; 20

标签: php jquery wordpress pagination


【解决方案1】:
<?php
/*
Template Name: emoticons-page
*/
get_header(); ?>
<div id="content">
    <div id="main">
        <?php 
        $paged = (get_query_var('page')) ? get_query_var('page') : 1;
        $posts_per_page = 20;
        query_posts('cat=44&post_status=publish&paged=' . $paged . '&posts_per_page=' . $posts_per_page);?>
        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
            <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
            <p><?php the_content(); ?>
        <?php endwhile; 
        posts_nav_link();
        wp_reset_query();
        endif; ?>
    </div>

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-06-18
  • 2016-11-07
  • 1970-01-01
  • 2014-01-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多