0

フッターに前のページと次のページへのリンクを追加したいので、各ページを 5 件の投稿に制限できます。次の投稿と前の投稿は必要ありません。これを WP ループの内外に入れようとしましたが、まだ機能していません! 私はこのWordPressのことはまったく初めてです。single.php については、すでに次の投稿と前の投稿を実装しています。以前の投稿と次の投稿を index.php や /categories/ などの他のページで使用したいが、single.php は使用したくない。

  <footer id="home-footer">

            <?php posts_nav_link('','<','>'); ?>



            <div class="wrapper">
                        <p id="home-extra">You can find more articles at the <a href="/archive">archive</a>.</p>
            </div><!--end .wrapper -->

        <div class="footer-wrapper">

                <div class="projects">

                    <h1 id="projects-title">Projects</h1>

                        <ul class="footer-list">
                            <li><a href="http://dribbble.com/MatthewKosloski/projects/129666-iOS-Betas">iOS Betas</a></li>              
                        </ul>

                </div><!-- end .projects -->

                <div class="recent">

                        <h1 id="recent-title">Recent Posts</h1>


                            <ul class="footer-list">    

                                <?php
                                    $args = array( 'numberposts' => '5' );
                                    $recent_posts = wp_get_recent_posts( $args );
                                    foreach( $recent_posts as $recent ){

                                        echo '<li><a href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' .   $recent["post_title"].'</a> </li> ';

                                    }
                                ?>

                            </ul>

                </div><!-- end .recent -->

        <div id="dribbble"><h1 id="recent-title">What i'm working on</h1></div>
        <script type="text/javascript" src = "https://halfcourtshot.googlecode.com/svn/tags/1/js/half-court-shot.jsapp.mh.min.js"></script>
        <script type="text/javascript">var hcs = new HalfCourtShot({ jersey: "matthewkosloski", shots: 3, goal: 'dribbble' });</script>                         

        </div><!-- end .footer-wrapper -->

            <div class="note-wrapper">

                <p id="note">&copy; 2013 Matthew Kosloski</p>

            </div><!-- end .note-wrapper-->

    </footer>
4

1 に答える 1

0

管理者設定 > 読み取り (wp-admin/options-reading.php) で、ページあたりの投稿数を 5 に変更します。

リンクについては、コーデックスに従って間違って書いています

これを試して

<?php posts_nav_link('','<','>'); ?>

アップデート:

このif/elseステートメントを追加して、単一またはインデックスで異なるものを表示できます

<?php if(is_single()) { // single-view navigation ?>

    <?php $posts = query_posts($query_string); if (have_posts()) : while (have_posts()) : the_post(); ?>

        <?php previous_post_link('%link', '<'); ?>  | <?php next_post_link('%link', '>'); ?>

    <?php endwhile; endif; ?>

<?php } else { // archive view navigation ?>

        <?php posts_nav_link('','<','>'); ?>

<?php } ?>

ここでさらにヘルプを参照してください

于 2013-06-07T21:11:13.467 に答える