WordPress.org

Ready to get started?Download WordPress

Forums

WP-PageNavi
[resolved] Option to always show First/Previous/Next/Last? (11 posts)

  1. jsherk
    Member
    Posted 2 years ago #

    This is a great plugin! Thanks...

    Is there an option to ALWAYS display the First, Previous, Next and Last buttons/links, even when they are not needed?

    Thanks

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

  2. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    Why would you need that?

  3. jsherk
    Member
    Posted 2 years ago #

    I just like the way it would look, so the page numbers themselves do not shift to the left when the First/Previous button disappears.

    If they are always shown (maybe greyed out if they don't apply) then the width of the pagenavi display would always remain fixed, and if I was displaying say 5 page numbers, only the numbers would change but would not move position.

    Thanks

  4. katymoon
    Member
    Posted 2 years ago #

    jsherk - did you ever find a way to do this?

  5. jsherk
    Member
    Posted 2 years ago #

    No I did not ... sorry :(

  6. shuvra124
    Member
    Posted 2 years ago #

    Open core.php

    For Previous
    at line 83:
    if ( $paged > 1 && !empty( $options['prev_text'] ) )

    change it like this:
    if ( 1 || $paged > 1 && !empty( $options['prev_text'] ) )

    For Next
    at line 141:
    if ( $paged < $total_pages && !empty( $options['next_text'] ) )

    change it like this:
    if ( 1 || $paged < $total_pages && !empty( $options['next_text'] ) )

    find First and Last, and just add 1 with OR condition.

    easy :)

  7. jsherk
    Member
    Posted 2 years ago #

    Awesome! Yes easy!

    Thanks

  8. shuvra124
    Member
    Posted 2 years ago #

    Oh there is a problem, when u r at last page then if u press next button it will try to go total page+1, and redirect to home page. to solve this problem add this code

    // Next
    if ( 1 || $paged < $total_pages && !empty( $options['next_text'] ) ) {
    if($paged = $total_pages)
    {
    $paged = $total_pages;
    }
    else {
    $paged++;
    }
    $out .= $instance->get_single( $paged, 'nextpostslink', $options['next_text'] );
    }

  9. Hiranthi
    Member
    Posted 1 year ago #

    Why hack the core? That only makes sure you need to re-apply the changes when there's an update of the plugin. I just added the previous / next links like this:

    <?php 
    
    // Pagina nummering
    if ( function_exists('wp_pagenavi') )
    {
    	ob_start();
    	wp_pagenavi();
    
    	$pagenavi = ob_get_contents();
    	ob_end_clean();
    
    	if ( !strstr($pagenavi, 'previouspostslink') ) $pagenavi = str_replace('<span', '<span class="previouspostslink">⇠ Vorige</span>'."\r\t".'<span', $pagenavi);
    	if ( !strstr($pagenavi, 'nextpostslink') ) $pagenavi = str_replace('</div>', '<span class="nextpostslink">Volgende ⇢</span>'."\r".'</div>', $pagenavi);
    
    	echo $pagenavi;
    }
    
    ?>

    And the same can be done for the first/last links.

  10. Hiranthi
    Member
    Posted 1 year ago #

    Oh and @jsherk, if the topic is resolved, could you please mark it like that too? :)

  11. Chantal Coolsma
    Member
    Posted 1 year ago #

    Thanks Hiranthi. Solved my problem too. See you soon! (hopefully)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic