簡體   English   中英

將分頁添加到Wordpress中靜態頁面上的自定義循環

[英]Add pagination to custom loop on a static page in Wordpress

我試圖將分頁鏈接甚至下一頁和上一頁鏈接添加到使用我不熟悉的自定義循環的wordpress上的靜態首頁上。 我對php / wordpress編解碼器的了解很少,無法弄清楚該如何實現。 以下是循環的完整代碼,任何幫助將不勝感激!

同樣,這似乎是二十一個WordPress主題的子主題。

    <?php

    global $post;

    //$args = array( 'numberposts' => 1, 'category' => 7 );

    //$args=array( 'numberposts' => -1, 'category' => -6 );



    $myposts = get_posts( $args );

    foreach( $myposts as $post ) :  setup_postdata($post); 

    //echo "<pre>";

    //print_r($post);

    ?>

  <div class="post_blog">
    <h1><a href="<?php the_permalink() ?>">
      <?php the_title(); ?>
      </a></h1>
    <div class="clr"> </div>
    <?php //the_date();?>
    <div class="post_cont">
      <div class="post_thum"> <a href="<?php the_permalink() ?>">
        <?php the_post_thumbnail();?>
        </a> <span class="post_slogn"><?php echo $cfs->get('post_slogen'); ?></span>
      </div>
      <div class="post_right">
        <p>
          <?php //content(120);
          content(100);
          //the_content("Continue reading " . the_title('', '', false)); 
          //content('<p style="text-align: justify;"><!--more--></p>');
          ?>
        </p>
        <div class="clr"> </div>
        <span class="read_entry"><a href="<?php the_permalink() ?>">MORE <span>»</span></a> </span>
        <div class="share"> <span class='st_facebook' st_title='<?php the_title(); ?>' st_url='<?php the_permalink(); ?>'></span><span class='st_twitter' st_title='<?php the_title(); ?>' st_url='<?php the_permalink(); ?>'></span><span class='st_linkedin' st_title='<?php the_title(); ?>' st_url='<?php the_permalink(); ?>'></span><!-- <span class='st_email' st_title='<?php //the_title(); ?>' st_url='<?php //the_permalink(); ?>'> --></span><span class='st_plusone' st_title='<?php the_title(); ?>' st_url='<?php the_permalink(); ?>'></span><span class='st_fblike' st_title='<?php the_title(); ?>' st_url='<?php the_permalink(); ?>'></span></div>
      </div>
      <div class="clr"></div>
 <div class="sub_title">
          <?php //the_tags(' ');
            the_tags('', ' ', ' ');

          ?>
        </div>
    </div>
  </div>

  <?php endforeach; ?>

如果您查看wordpress編解碼器,您會發現有一個呼叫下一個和上一個帖子的鏈接。

 <?php next_post_link('%link', 'Name of your next post link', TRUE); ?>
 <?php previous_post_link('%link', 'Name of your previous post link', TRUE); ?>

此外,您應該閱讀有關如何在wordpress循環中實現分頁的交流

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM