简体   繁体   中英

changing permalink gives 404 eror in navigation [wordpress]

i made a page template gallery which shows custom post type named gallery which consists of a custom fields image and title Now when i run the below code and click the paginate button it directs me to http://localhost/KURDC/gallery/page/2/ and it redirects me to 404 page . why is the pagination not working ?

But when i change the permalink to default it works ! what is the problem with change in permalink ?

<?php /*template name:gallery*/ ?>

           <?php
          $wp_query = null; 
      $wp_query = new WP_Query(); 
       $wp_query->query('showposts=2&post_type=gallery'.'&paged='.$paged); 

    while ($wp_query->have_posts()) : $wp_query->the_post(); 

             $wp_query = null; 
      $wp_query = new WP_Query(); 
       $wp_query->query('showposts=2&post_type=gallery'.'&paged='.$paged); 

                $image = get_field( 'photo' );
                $url    = $image['url'];        
        ?>      
        <div class="galleryContainer">
        <img src="<?php echo $url; ?>">
        <div class="caption"><?php the_field('title'); ?></div>
        </div>

            <?php endwhile; ?>
    <?php wp_reset_postdata(); // reset the query ?>
                            <nav>
                             <div class="right">
        <?php previous_posts_link('&laquo; Newer') ?>
    <div class="left">
    <?php next_posts_link('&laquo; Older ') ?>
    </div>  

找到了我自己的问题的答案:D将代码添加到自定义帖子类型中为我节省了:)

'rewrite' => array('slug' => 'slug-name','with_front' => FALSE)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM