1179 posts
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 200 and 499 users
  • Has been a member for 6-7 years
mabuc says

Hello wordpress masters,

I need your help…
I have here a function of page pagination and all I want is not to display the div.pagination and Page 1 of 3 when the page is equal to 1

here’s my code:
function pagination() {  
        global $wp_query;
        $big = 999999999;
        echo "<div class="\"pagination" clear="">";
        echo paginate_links( array(
            'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
            'format' => '?paged=%#%',
            'current' => max( 1, get_query_var('paged') ),
            'total' => $wp_query->max_num_pages,
            'type' => 'list'
        ));
        echo "<span class="\"count\"">Page " . max(1, get_query_var('paged') ) . " of " . $wp_query->max_num_pages . "</span>";
        echo "</div>";
    }

I hope someone can help.. I’m using paginate_links. I also check codex about this function but can’t find any solutions.

thanks
mark

1179 posts
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 200 and 499 users
  • Has been a member for 6-7 years
mabuc says

oh nevermind.. I got it sorted, maybe someone needs it ;)

function pagination() {  
        global $wp_query;
        $big = 999999999;
        if($wp_query->max_num_pages == '1' ) {
        }else {
            echo "<div class="\"pagination" clear="">";
        }
        echo paginate_links( array(
            'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
            'format' => '?paged=%#%',
            'current' => max( 1, get_query_var('paged') ),
            'total' => $wp_query->max_num_pages,
            'type' => 'list'
        ));
        if($wp_query->max_num_pages == '1' ) {
        }else {
            echo "<span class="\"count\"">Page " . max( 1, get_query_var('paged') ) . " of " . $wp_query->max_num_pages . "</span>";
            echo "</div>";
        }
    }
by
by
by
by
by
by