WordPress.org

Ready to get started?Download WordPress

Forums

WP-PageNavi
[resolved] Where to put this code in twenty ten themes? (5 posts)

  1. cascd88
    Member
    Posted 4 years ago #

    hi all. i've already activate this plugin but still not sure where to placed this plugin in twenty ten themes. anyone please help me coz i really need this plugins. Thanks you all.

    http://wordpress.org/extend/plugins/wp-pagenavi/

  2. yiotta
    Member
    Posted 3 years ago #

    I found this works in my WP 3.0 theme (not twenty ten, but similar, so YMMV):

    In functions.php, find the section referring to the page_navi: in my theme, function page_navi.

    Locate at the bottom of that paragraph of code

    $prev_link = get_previous_posts_link(__('Newer Entries »', THEME_NS));
            $next_link = get_next_posts_link(__('« Older Entries', THEME_NS));

    Comment that out and add instead
    if(function_exists('wp_pagenavi')) { wp_pagenavi(); }

    So, altogether in my theme it looks like:

    function art_page_navi($title = '', $comment = false) {
        $prev_link = null;
        $next_link = null;
        if($comment){
            $prev_link = get_previous_comments_link(__('Newer Entries »', THEME_NS));
            $next_link = get_next_comments_link(__('« Older Entries', THEME_NS));
        } elseif (is_single() || is_page()) {
            $next_link = get_previous_post_link('« %link');
            $prev_link = get_next_post_link('%link »');
        } else {
            if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
    		/*$prev_link = get_previous_posts_link(__('Newer Entries »', THEME_NS));
            $next_link = get_next_posts_link(__('« Older Entries', THEME_NS));*/
        }

    HTH. I'm not much of a coder, but it works for me (needs styling, though).

  3. acefav
    Member
    Posted 3 years ago #

    Step1:Activate WP-PageNavi
    Step2: find the following code in your loop.php

    <?php /* Display navigation to next/previous pages when applicable */ ?>

    Step3:
    =============DELETE Star=============

    <?php if ( $wp_query->max_num_pages > 1 ) : ?>
    <div id="nav-above" class="navigation">
    <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentyten' ) ); ?></div>
    <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentyten' ) ); ?></div>
    </div><!-- #nav-above -->
    <?php endif; ?>

    =============DELETE END==============

    Step4:
    Add

    <?php wp_pagenavi(); ?>

    instead of the DELETED code in Step3,Then update loop.php.Finished!!!

    PS:It has 2 places to change In loop.php, if all changed , one PageNavi button will display in top of the page and an other PageNavi Button will display in bottom of the page.

    My personal blog http://hh.0745666.com was in trouble like yours, and now, works fine!

    Hope can help you :)

  4. cascd88
    Member
    Posted 3 years ago #

    thanks acefav! its really help! :-D
    i just change the lowest code.. =D

  5. sacredpractice
    Member
    Posted 3 years ago #

    hi acefav and cascd88,
    i did this in my theme however it didn't work... perhaps because I'm using custom post types?

    there is no other place i need to put the code so it appears in a custom post type?

    any help would be greatly appreciated! thnx

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic