2016-04-18 6 views
0

WP_Queryを使用して私のカスタムページに簡単なページングを追加しようとしました。しかし、次のページのリンクをクリックすると、常にindex.phpに行きます(私のテーマにはまだ404.phpがありません)Wordpress:ページの次のページは常にindex.phpに戻る

このページは私のカスタムページのページ番号

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

    while ($wp_query->have_posts()) : $wp_query->the_post(); 
    ?> 
    <div class="col-md-3 col-sm-4 article-list" data-sr='enter bottom, move 50px, over 0.5s'> 
     <a href="<?php the_permalink(); ?>"><p class="article-link-img"><?php the_post_thumbnail('small-thumbnail'); ?></p> 
     <p class="article-link-title"><?php the_title(); ?></p></a> 
    </div> 

    <?php endwhile; ?> 
    <nav> 
    <?php previous_posts_link('&laquo; Newer') ?> 
    <?php next_posts_link('Older &raquo;') ?> 
    </nav> 
    <?php 
    $wp_query = null; 
    $wp_query = $temp; // Reset 
    ?> 

、これが私のindex.phpのコード

<?php get_header(); ?> 

<div class="container index-section"> 
    <section> 
    <div class="row"> 
     <div class="col-md-12"> 
     <?php if (have_posts()) : while (have_posts()) : the_post(); ?> 
      <p><?php the_content(); ?></p> 
     <?php endwhile; else: ?> 
      <h1 class="index-error-message"><?php _e('Sorry, this post does not exist.'); ?></h1> 
      <h2 class="single-article-popular-title">Popular Articles</h2> 
      <?php 
       $topBlogs = new WP_Query('orderby=rand&cat=3&posts_per_page=4'); 

       if ($topBlogs -> have_posts()) : 
       while ($topBlogs -> have_posts()) : $topBlogs -> the_post(); ?> 
       <div class="col-md-3 col-sm-3 col-xs-6 single-article-popular-list"> 
        <a href="<?php the_permalink(); ?>"><p><?php the_post_thumbnail('small-thumbnail'); ?></p> 
        <p class="single-article-popular-link-title"><?php the_title(); ?></p></a> 
       </div> 
       <?php endwhile; else: ?> 
       <h3>No content found</h3> 
       <?php endif; ?> 
     <?php endif; ?> 
     </div> 
    </div> 
    </section> 
</div> 

<?php get_footer(); ?> 

である私は、問題が何であるか、それを考え出ししようとしていたが、それでも解決策を持っていません。私もWP_PageNAViプラグインを使用しようとしましたが、同じ結果が残っています。

これは私のカスタムページの完全なコード

<?php get_header(); ?> 

    <div class="article-featured"> 
     <div class="container"> 
     <section> 
      <div class="row"> 
      <?php 
       $featuredBlogs = new WP_Query('cat=4&posts_per_page=1'); 

       if ($featuredBlogs -> have_posts()) : while ($featuredBlogs -> have_posts()) : $featuredBlogs -> the_post(); ?> 
       <div class="col-md-12 article-featured-descr"> 
        <a href="<?php the_permalink(); ?>"><p class="article-featured-descr-text" data-sr='enter bottom, move 50px, over 0.5s'>Featured article</p> 
        <h1 data-sr='enter bottom, move 50px, wait 0.3s, over 0.5s'><?php the_title(); ?></h1> 
        <img src="/ecteciant/wp-content/themes/ecteciant/files/images/article/no-article.png" alt="no article" data-sr='enter bottom, move 50px, wait 0.6s, over 0.5s'></a> 
       </div> 
       <?php endwhile; else: ?> 
       <div class="col-md-12 article-featured-descr"> 
        <p class="article-featured-descr-text" data-sr='enter bottom, move 50px, over 0.5s'>No featured article found</p> 
        <img src="/ecteciant/wp-content/themes/ecteciant/files/images/article/no-article.png" alt="no article" data-sr='enter bottom, move 50px, wait 0.3s, over 0.5s'> 
       </div> 
       <?php endif; ?> 
      </div> 
     </section> 
     </div> 
    </div> 


    <div class="container"> 
     <section> 
     <div class="row"> 
      <?php 
      $temp = $wp_query; 
      $wp_query = null; 
      $wp_query = new WP_Query(); 
      $wp_query->query('showposts=2&cat=2'.'&paged='.$paged); 

      while ($wp_query->have_posts()) : $wp_query->the_post(); 
      ?> 
      <div class="col-md-3 col-sm-4 article-list" data-sr='enter bottom, move 50px, over 0.5s'> 
       <a href="<?php the_permalink(); ?>"><p class="article-link-img"><?php the_post_thumbnail('small-thumbnail'); ?></p> 
       <p class="article-link-title"><?php the_title(); ?></p></a> 
      </div> 

      <?php endwhile; ?> 
      <nav> 
      <?php previous_posts_link('&laquo; Newer') ?> 
      <?php next_posts_link('Older &raquo;') ?> 
      </nav> 
      <?php 
      $wp_query = null; 
      $wp_query = $temp; // Reset 
      ?> 

      <div class="col-md-12 article-not-found"> 
      <img src="/ecteciant/wp-content/themes/ecteciant/files/images/article/submit-article.png" alt="submit article" data-sr='enter bottom, move 50px, over 0.5s'> 
      <p data-sr='enter bottom, move 50px, wait 0.3s, over 0.5s'>What do you think about <b>"A"</b>? How about <b>"B"</b>?<br/>Send your thoughts to <a href="mailto:[email protected]?Subject=New%20Article%20Inquiry">[email protected]</a>, we accept from <b>A to Z.</b> Our team will review your submission.<br/>Stand a chance to be <b>FEATURED</b> in our page.</p> 
      </div> 
     </div> 
     <!--<iframe src="https://www.facebook.com/plugins/share_button.php?href=https%3A%2F%2Fbudilokawijaya.com&layout=button_count&mobile_iframe=true&width=86&height=20&appId" width="86" height="20" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe> 

     <a href="https://twitter.com/intent/tweet?button_hashtag=ecteciantID" class="twitter-hashtag-button" data-related="budi_czras,ecteciantID" data-url="http://ecteciant.com">Tweet #ecteciantID</a>--> 
     </section> 
    </div> 

<?php get_footer(); ?> 

答えて

1

である私は、この問題を解決する別のフォーラムからの回答を見つけました。

[ブログに読む]ページの管理者を変更すると、最大= 1が表示され、問題が解決されました。しかし、なぜこれが問題を解決したのか分からず、これを行うことによって何らかの欠点があるかどうかもわかりません。

少なくともこれが問題を解決しました。

誰かがより良い解決策を知っている場合は、ソリューションを投稿してください。

+0

誰かが不思議に思うのであれば、この特定の設定はどこですか、管理者用メニューを開き、*設定*→*読書*に行きます。 – Ghost

関連する問題