1179 posts
  • Has referred 200+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+2 more
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
  • Has referred 200+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+2 more
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>";
        }
    }

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by