0

これを確認するために時間を割いていただきありがとうございます。

私はこれに数日を費やしました。wp.​​org で多くの時間を過ごしましたが、私はそれを理解していません。きっと簡単に修正できるはずです。何を試しても、ページごとの投稿数を制限したり、ページネーションを表示したりすることはできません。これは私の最近の試みです (私の最善の試みではないかもしれません)。このページには、すべての投稿または最近の投稿または何か (私のサイトではない) が表示されます。少なくとも投稿を制限するページを取得できたら、ページネーションに取り組みます。また、WP ダッシュボードでページごとの投稿を設定しても何もしません...そして決してしませんでした。そのため、自分で何かをコーディングしようとしています。ページごとの投稿数を制限できないのはなぜですか? ページネーションを現在持っている場所に配置しますか? これは完全な混乱ですか、笑?

再度、感謝します、

Dave (以下のコード)

<?php /* Template Name: Stories */ ?>

<?php 

get_header(); ?>

    <!-- *************************************** -->    
    <div class="custom_two_third">

<?php

// The Query

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array('posts_per_page' => 3, 'paged' => $paged );



$the_query = new WP_Query($args);

// The Loop
if ( $the_query->have_posts() ) {

    while ( $the_query->have_posts() ) {
        $the_query->the_post();
        get_template_part( 'template-parts/content', get_post_format() );
    }

// pagination
next_posts_link();
previous_posts_link();

} else {
    get_template_part( 'template-parts/content', 'none' );
}



/* Restore original Post Data */
wp_reset_postdata();
?>

    <div class="clear"></div>

    </div><!-- custom_two_third -->
<?php 

    get_sidebar(); 

    get_footer(); 

?>
4

3 に答える 3

0
// the query
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$news_eve_args = array( 'post_type' => 'news_events', 'posts_per_page' => 4, 'paged' => $paged);
$wp_query = new WP_Query( $news_eve_args );
if ( $wp_query->have_posts() ) : ?>
    <?php while ( $wp_query->have_posts() ) : $wp_query->the_post();?>
          <?php the_title(); echo "<br/>"; ?>
    <?php endwhile; ?>
    <nav>
      <?php previous_posts_link('&laquo; Newer',$wp_query->max_num_pages); ?>
      <?php next_posts_link('Older &raquo;',$wp_query->max_num_pages); ?>
    </nav>
    <?php wp_reset_postdata(); ?>                           
    <?php else : ?>
        <p><?php _e( 'Sorry, no news or events  at this time.', 'theme' ); ?></p>
<?php endif; ?>
于 2015-09-19T05:11:13.313 に答える