logo
Ask your WordPress questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$15
How to add WP-PageNavi pagination to [gallery] shortcode?

I have the WP-PageNavi plugin installed but would like to know how I can use it to paginate the built in wordpress gallery shortcode?

For instance I want to upload 100 images and display the gallery in 5 pages of 20 images with pagination to navigate back and forth.

I would prefer not to use another plugin to achieve this as I like WP-PageNavi a lot and have also styled it with css to fit my theme perfectly.

julesphoto | 12/04/11 at 12:55pm Edit
Tutorial: How to assign prize money

Previous versions of this question: 12/04/11 at 1:18pm | 12/04/11 at 1:31pm

(6) Possible Answers Submitted...

See a chronological view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    12/04/11
    1:05pm
    Fahd Murtaza says:

    Apparently, this plugin doesn't do gallery paging.

    But this plugin does

    http://wordpress.org/extend/plugins/paged-gallery/

    Please read its FAQ.

    Previous versions of this answer: 12/04/11 at 1:04pm | 12/04/11 at 1:05pm

    • 12/04/11 1:19pm

      julesphoto says:

      Thanks for the input, I would prefer to not use another plugin and work WP-PageNavi in to the solution as it is a great pagination solution.

    • 12/04/11 1:20pm

      Fahd Murtaza says:

      OK

  • avatar
    Last edited:
    12/04/11
    3:37pm
    Julio Potier says:

    Hello

    i Just read the core code for WP Page Navi and this plugin work for posts only and a gallery is not a post.
    So the plugin can not do this work.
    Same for the core code for [gallery], there is no way to tell this shortcode "only 20 posts please".
    In this 2 core codes, filters exists, i think something can be done ... but using a plugin is the best way to do this ...
    ;)

  • avatar
    Last edited:
    12/04/11
    11:42pm
    Jatin Soni says:

    Download paginated-gallery plugin from this link http://www.phil-barker.com/2011/04/wordpress-gallery-pagination-plugin/

    Than extract and place into plugin folder and activate it.

    Now use [ paginated_gallery ] shortcode to get gallery or use standard [ gallery ] shortcode. Note: To use wordpress native shortcode [ gallery ] you must have to define use native gallery option in settings.

    All settings can be found in Settings > Paginated Gallery. its very easy.

    Previous versions of this answer: 12/04/11 at 11:42pm

  • avatar
    Last edited:
    12/05/11
    11:46am
    nina magbanua says:

    hi,

    you can go to you admin and check under settings there's a PageNavi settings. You can update your settings here without setting anything on your code:

    Please refer to this link:

    http://clip2net.com/s/1njjR

  • avatar
    Last edited:
    12/05/11
    8:17pm
    Francisco Javier Carazo Gil says:

    If you are using galleries with images that are saved into database as attachment, you may try to do this:


    <?php
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    $wp_query = new WP_Query(array('post_type' => 'attachment',
    'paged' => $paged,
    'post_per_page' => 10)
    );
    while ($wp_query->have_posts()) : $wp_query->the_post();
    ?>

  • avatar
    Last edited:
    12/07/11
    11:07am
    yves vu says:

    hi julesphoto,
    you should create a private page to view your gallery.
    a file gallerynew-page.php in folder your theme.
    Code as:

    <?php
    /*
    Template Name: gallery Page
    */
    ?>
    <?php get_header(); ?>
    <?php $postindex = 1;
    $my_query = new WP_Query( array('paged' => get_query_var('paged') ) );
    if ( $my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <div class="postBox <?php if(($postindex % 3) == 0){ echo 'lastBox';}?>">
    <div class="postBoxInner">
    <?php
    if(has_post_thumbnail()) {
    //the_post_thumbnail();?>
    <img src="<?php echo get_image_path($post->ID); ?>" alt="<?php the_title(); ?>">
    <?php } else {
    echo '<img src="'.get_bloginfo("template_url").'/images/nothumb.jpg" alt="No Thumbnail"/>';
    }?>

    <h2><a href="<?php the_permalink() ?>" ><?php the_title(); ?></a></h2>
    </div>
    </div>
    <?php ++$postindex; ?>
    <?php endwhile; ?>
    <?php if (function_exists('wp_pagenavi')) wp_pagenavi(array( 'query' => $my_query ));
    wp_reset_postdata(); // avoid errors further down the page
    ?>

    <?php else : ?>

    <p>Sorry, but you are looking for something that isn't here.</p>

    <?php endif;
    wp_reset_query();?>

    <?php get_footer(); ?>



    This code use plugin PageNavi to view gallery and it's good for my projects.
    You can config "5 pages of 20 images" in config of PageNavi
    Hope useful for you.

    Previous versions of this answer: 12/07/11 at 11:07am

This question has expired.





Current status of this question: Community pot



Please log in to add additional discourse to this page.





Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.