How can I add pagination to my Media tags code?
-
I have the following code in my taxonomy-media-tags.php template file. How do I add pagination to this please so that my page will only display a specified number of photos per page? I’ve see the numberpost parameter that i can use within the ‘get_attachments_by_media_tags’ args but that doesn’t help with pagination. Thanks
<?php get_header(); ?> <?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); ?> <?php $media_items = get_attachments_by_media_tags('size=thumb&media_tags='.$term->slug); ?> <?php echo '<h1>You are viewing all photos tagged <i>'. $term->name . '</i></h1>'; ?> <?php if ($media_items) { echo '<ul>'; foreach ($media_items as $mymedia) { $fullSize = wp_get_attachment_url($mymedia->ID); $taggedThumbnail = wp_get_attachment_thumb_url($mymedia->ID, 'thumb'); $associatedPost = get_permalink($mymedia->post_parent); $parent_title = get_the_title($mymedia->post_parent); $image_title = $mymedia->post_title; echo '<li><a href="' . $fullSize . '" rel="shadowbox[set1]" title="Click to view this “'. $term->name . '” photograph in fullscreen. Filename: '. $image_title .'.jpg" ><img src="'.$taggedThumbnail.'" alt="Photograph filename:'. $image_title .'.jpg" /></a> <span>This photo can also be seen here: <a href="' . $associatedPost . ' " title="View “'. $parent_title .'”">' . $parent_title . '</a></span> </li>'; } echo '</ul>'; } ?> <?php // Reset Post Data wp_reset_postdata(); ?> <?php get_footer(); ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘How can I add pagination to my Media tags code?’ is closed to new replies.