WP2.5 Gallery pagination? (13 posts)

  1. activateru
    Posted 8 years ago #

    Hello, team!

    I couldn't find any pagination options for posts containing gallery featured in WP 2.5

    My design template requires post paginating and I really want to use a buil-in gallery rather than different plugins. Is there any way to fix that?


  2. mnogueir
    Posted 8 years ago #

    I opened an enhancement request for this: http://trac.wordpress.org/ticket/6455

  3. activateru
    Posted 8 years ago #

    thank you so much. i hope there will be a fix for that

  4. harknell
    Posted 8 years ago #

    Have you tried out any of the image gallery plugins that exist for WordPress? While the built in one is nice for a quick and dirty gallery, for anything really advanced you'll want to look at a dedicated plugin. I doubt they'll be really spending a ton of time developing the built in one.

  5. activateru
    Posted 8 years ago #

    Currently i do use NextGEN Gallery plugin but i don't really like it. It doesn't allow comments on each image and it's not so usable and much more complicated that built-in galleries in 2.5

    if there are better plugins please let me know i'll try them as well.
    also i noticed the ticket created by Mnogueir is due to version 2.7 so it seems that it will be a long waiting

  6. mnogueir
    Posted 8 years ago #

    @activateru: The "2.7" target is the default value; if anyone thinks this is an important question, it could be solved sooner...

  7. Evita
    Posted 8 years ago #

    Navigation for images within a gallery:
    <?php previous_image_link(); ?> <?php next_image_link(); ?>

  8. mnogueir
    Posted 8 years ago #

    @Evita: Right, but what we wanted was the possibility of automatically (based on number of thumbnails, for example) paginate the gallery...

  9. henri
    Posted 8 years ago #

    Did you find the solution? If yes I'm interested ;)

  10. obsediado
    Posted 7 years ago #

    Tá muito difícil pra mim também exibir todas as galerias de um álbum, pois tenho 100 galerias dentro de um álbum - meu site é sobre filmes, cada galeria corresponde a um filme, cada álbum corresponde a um gênero de filme. São muitas galerias para carregar em uma só página, fica muito leeeeento.

    I also have difficulty to display all the galleries of an album, because I have 100 galleries within an album - my site is about movies, each gallery is for one movie, each album is a genre of movie. Many galleries to load into a single page, it's sloooooooooow.

    Sorry the wrong words, I don't understand english.

  11. Ovidiu
    Posted 7 years ago #

    any news on this? I am using wp 2.7 beta3 and still no pagination :-(

  12. Ovidiu
    Posted 7 years ago #

    ach shit. the target for this has been changed :-(

    10/13/08 22:41:28 changed by ryan ¶

    * milestone changed from 2.7 to 2.8.

    thats a really important feature... who would like to have a gallery with 150+ pictures load on one page :-( grrr..

  13. smooth criminal
    Posted 7 years ago #

    well i wrote some very Very VERY DUMB code that does what it needs to split the gallery into pages. In worst case scenario (last page) it queries all thumbnail but still displays only limited amount.

    this script registers new shortcode [mygallery] which accepts new parameter limit=x and it's compatible with built in wp gallery so other options and cutomisations still apply.

    example: [mygallery limit="20"]

    it puts some ugly $_GET values in url but still: does it's thing

    da CODE (paste it in functions.php):

    add_shortcode('mygallery', 'mygallery_shortcode');
     * The myGallery shortcode.
     * This implements the functionality of the Gallery Shortcode for displaying
     * WordPress images on a post.
     * @since 2.5.0
     * @param array $attr Attributes attributed to the shortcode.
     * @return string HTML content to display gallery.
    function mygallery_shortcode($attr) {
    	global $post;
    	// Allow plugins/themes to override the default gallery template.
    	$output = apply_filters('post_gallery', '', $attr);
    	if ( $output != '' )
    		return $output;
    	// We're trusting author input, so let's at least make sure it looks like a valid orderby statement
    	if ( isset( $attr['orderby'] ) ) {
    		$attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
    		if ( !$attr['orderby'] )
    			unset( $attr['orderby'] );
    	if (!isset($_GET['gal_page'])) $gal_page = 0; else $gal_page = $_GET['gal_page'];
    		'order'      => 'ASC',
    		'orderby'    => 'menu_order ID',
    		'id'         => $post->ID,
    		'itemtag'    => 'dl',
    		'icontag'    => 'dt',
    		'captiontag' => 'dd',
    		'columns'    => 3,
    		'size'       => 'thumbnail',
    		'limit'      => 0
    	), $attr));
    	$id = intval($id);
    	$attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby, 'numberposts' => $limit*(1+$gal_page)) );
    	if ( empty($attachments) )
    		return '';
    	if ( is_feed() ) {
    		$output = "\n";
    		foreach ( $attachments as $id => $attachment )
    			$output .= wp_get_attachment_link($id, $size, true) . "\n";
    		return $output;
    	$itemtag = tag_escape($itemtag);
    	$captiontag = tag_escape($captiontag);
    	$columns = intval($columns);
    	$itemwidth = $columns > 0 ? floor(100/$columns) : 100;
    	if($gal_page > 0)
    	$previous_link = '<a href="'.get_permalink() .'&gal_page='. ($gal_page-1) .'#gallery-'.$id.'">Previous Page</a>';
    	if(((count($attachments)) - ($gal_page+1)*$limit) == 0)
    	$next_link = '<a href="'.get_permalink() .'&gal_page='. ($gal_page+1) .'#gallery-'.$id.'">Next Page</a>';
    	$output = apply_filters('gallery_style', "
    		<style type='text/css'>
    			.gallery {
    				margin: auto;
    			.gallery-item {
    				float: left;
    				margin-top: 10px;
    				text-align: center;
    				width: {$itemwidth}%;			}
    			.gallery img {
    				border: 2px solid #cfcfcf;
    			.gallery-caption {
    				margin-left: 0;
    		<!-- see mygallery_shortcode() in themes/totalwar/functions.php -->
    		<div id='gallery-".$id."' class='gallery'>".$next_link.$previous_link.'<br style="clear: both" />');
    	$i = 0;
    	$j = 0;
    	$skip = $limit*$gal_page;
    	foreach ( $attachments as $id => $attachment ) {
    		if($j++ < $skip) continue;
    		$link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
    		$output .= "<{$itemtag} class='gallery-item'>";
    		$output .= "
    			<{$icontag} class='gallery-icon'>
    		if ( $captiontag && trim($attachment->post_excerpt) ) {
    			$output .= "
    				<{$captiontag} class='gallery-caption'>
    		$output .= "</{$itemtag}>";
    		if ( $columns > 0 && ++$i % $columns == 0 )
    			$output .= '<br style="clear: both" />';
    	$output .= "
    			<br style='clear: both;' />".$next_link.$previous_link.'<br style="clear: both" />'."
    	return $output;

Topic Closed

This topic has been closed to new replies.

About this Topic