嗨有一个问题,我无法在静态首页上进行分页,查看了 wordpress codex 并完成了它所说的构建但仍然没有乐趣,
非常感谢任何帮助
<?php
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
$type = 'Galleries';
$args=array(
'category_name' => 'Gallery',
'post_status' => 'publish',
'posts_per_page' => 2,
'paged' => $paged
);
$my_query = null;
$my_query = new WP_Query($args);
?>
<section id="maincontent" class="twelve columns">
<ul id="gallery_menu">
<?php if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li class="gallery_titleframe">
<div class="gallery_titleborder">
<div class="gallery_titleimage">
<?php $str = get_the_ID() ; ?>
<a href="<?php the_permalink() ?>" title="<?php echo get_post_meta($str, 'gallery1', true); ?>">
<img src="<?php echo get_post_meta($str, 'gallery1', true); ?>" width="256" height="186">
</a>
</div>
</div>
<div class="gallery_titletext">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</div>
</li>
<?php endwhile;
} ?>
<div id="nav-below" class="navigation">
<div class="nav-previous"><?php next_posts_link(); ?></div>
<div class="nav-next"><?php previous_posts_link(); ?></div>
</div><!-- #nav-below -->
<?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>