doulianxi0587 2014-10-18 07:38
浏览 99
已采纳

永久链接结构更改时,自定义页面模板分页不起作用

I created a page template at http://www.durgeshsound.com/gallery/ Here my pagination buttons are not working. this issue arises when permalink format is http://www.testsite.com/sample-post/ But when I set permalink format to default for example http://testsite.com/?p=123 then it starts working and creates a working pagination link like this http://www.durgeshsound.com/?page_id=81&paged=2.

I want this format http://www.testsite.com/sample-post/ in the links.

here is what i tried for custom page template

<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                            query_posts('post_type=gallery&posts_per_page=9&paged=' . $paged);  ?>
                        <?php if (have_posts()) : while (have_posts()) : the_post(); 

                        if ( get_post_gallery() ) :
                            $gallery = get_post_gallery( get_the_ID(), false );

                    ?>  
                    <?php the_post_thumbnail('large'); ?> 

                            <?php the_title(  ); ?>                                  

                    <?php
                        endif;
                    endwhile;   endif;
                ?> 

            <?php kriesi_pagination(); ?>  
              <?php get_sidebar('gallery'); ?>


<?php get_footer(); ?>

Please help.

  • 写回答

1条回答 默认 最新

  • dreamy1992 2014-10-18 08:47
    关注

    Below is custom Page : Replace $cat with your resp. ID

    <ul class="clearfix">
    <?php  
    
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;   
    
    $recentPosts = new WP_Query(); 
    $recentPosts->query("cat=$cat&showposts=10&paged=".$paged); ?>
    <?php  if($recentPosts){ ?>
    
    <?php if ( $recentPosts->have_posts() ): while ($recentPosts->have_posts()) : $recentPosts->the_post();  ?>
    
    <li id="post-<?php the_ID(); ?>" <?php post_class('interview-list'); ?>>
    <div class="video-thumb">
    <a href="<?php the_permalink(); ?>" rel="bookmark"><?php if(has_post_thumbnail()) {  
    the_post_thumbnail(array(500,393));
    }else {
    echo '<img src="'.get_bloginfo("template_url").'/images/no-image.jpg" width="500px" height="393px"/>';
    }
    ?>  </a>
    </div>
    <div class="image-con">
    <div class="int-title">
    <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
    </div>
    </div>
    </li>
    
    <?php endwhile; ?>
    
    <?php else: ?>
    <h2 class="post-title">No Photos</h2>
    <?php endif; ?>
    <div class="older-link"><?php next_posts_link('&laquo; Older Entries', $recentPosts->max_num_pages) ?></div>
    <div class="newer-link"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    <?php } ?>
    </ul>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大