• Hello!
    I’m having a problem with my pagination.
    I want it to work like this:
    The output: <1>
    The left arrow is a link for privious entries, the right arrow for next entries, and the “1” is the pagenumber.

    And if there’s no privious entries for instance, i want the arrow to still be there, but un-clickable.
    This is my current code (It’s ofcourse not working at the moment):

    <?php if(count(next_posts_link()) > 0): echo "the link..."; ?>
            <?php else: echo "the link, but unclickable"; ?>
            <?php endif; ?>
           //Below this is working
               <?php next_posts_link('<') ?>
    		   <?php if(!empty($_GET["paged"])) { echo '<strong>'.$_GET["paged"].'</strong>'; } else { echo "<strong> 1 </strong>"; } ?>
    		   <?php previous_posts_link('>') ?>
Viewing 15 replies - 1 through 15 (of 17 total)
  • Thread Starter felixkarlsson

    (@felixkarlsson)

    //Some code here that will find out if there is newer entries...
    <?php next_posts_link('<') ?>
    <?php
    if(!empty($_GET["paged"])) {
    echo '<strong>'.$_GET["paged"].'</strong>';
    }
    else { echo "<strong> 1 </strong>"; }
    ?>
    //Some code here that will find out if there is privious entries...
    <?php previous_posts_link('>') ?>
    Thread Starter felixkarlsson

    (@felixkarlsson)

    No sorry, those can’t help me.
    Because I just want one left arrow, and one right arrow.
    (Or i don’t want, but my client does…)

    And even if there’s no “Next page”, I want the arrow to still be there, but not as a link.
    So the thing I need is some function that will find out if there is a “next link” or “previous link”…

    Thanks!

    Felix Karlsson

    Thread Starter felixkarlsson

    (@felixkarlsson)

    Anyone?

    Try adding “<?php wp_link_pages(array(‘before’ => ‘<p>Pages: ‘, ‘after’ => ‘</p>’, ‘next_or_number’ => ‘number’)); ?>” to the page and single PHP files.

    Thread Starter felixkarlsson

    (@felixkarlsson)

    Can you elaborate that?
    I can’t see how that would solve the problem, sorry.

    Thanks!

    Felix Karlsson

    This will put the “next” or “>” for your pages.

    Thread Starter felixkarlsson

    (@felixkarlsson)

    Weird, it doesnt work? :S

    Works for me. See it in action on my site. Click on my profile to get to see it working on my site.
    Thanks,

    Thread Starter felixkarlsson

    (@felixkarlsson)

    Oh, but I don’t want it like that. ??
    I just want “< number >”
    number = The page that you’re at
    The arrows are the next-link and previous-link.

    And even though there is no next/previous link, there should be an unclickable arrow.

    Don’t know how to explain it better.

    Ex. <1>

    Thanks

    Felix Karlsson

    Thread Starter felixkarlsson

    (@felixkarlsson)

    I really need to solve this people, any suggestions?

    Thanks

    Felix Karlsson

    If you have this..

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    Divide the IF and WHILE conditions like so..

    <?php if (have_posts()) : ?> 
    
    	<?php while (have_posts()) : the_post(); ?>

    Then place this between them..

    <?php
    $totalposts = $wp_query->found_posts;
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $per_page = get_query_var('posts_per_page');
    $last_page = ceil($totalposts / $per_page);
    
    if($paged > 1) { previous_posts_link('<'); }
    else { echo '<';}
    
    echo $paged;
    
    if($last_page > $paged) { next_posts_link('>'); }
    else { echo '>';}
    ?>

    That what you’re after? ??

    Thread Starter felixkarlsson

    (@felixkarlsson)

    That’s exactly what I want! ??
    But I use the next link first, so I go back to earlier entries with “<” ??

    Thanks a lot!
    You’re my hero ??

    Felix Karlsson

    Hey felixkarlsson do you have the code for what you did? I would like to try it out too.
    Thanks.

    Thread Starter felixkarlsson

    (@felixkarlsson)

    Hey!

    I use this:

    <?php
    	$totalposts = $wp_query->found_posts;
    	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	$per_page = get_query_var('posts_per_page');
    	$last_page = ceil($totalposts / $per_page);
    
    	if($last_page > $paged) { next_posts_link('< '); }
    	else { echo '< ';}
    
    	echo "<strong>" .$paged. "</strong>";
    
    	if($paged > 1) { previous_posts_link(' >'); }
    	else { echo ' >';}
    ?>

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Pagination’ is closed to new replies.