how set up the number of attachments
-
hi,
i use pods in my template single-$podsname.php.
how could i set up the parameter of “numberposts” like within the wp_get_attachment_image function, because pagination of attached images is not needed?
here my written code at this moment:<?php //pods_image if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <?php $images = get_post_meta( $post->ID, 'works' ); foreach ( $images as $image ) { $testtitel = get_the_title(); echo '<li class="nav3"><a title="'.$testtitel.' - '.$image['post_title'].'" class="thumb" href="'.$image['guid'].'">'.pods_image( $image, 'works-navi' ).'</a> <div class="caption"> <div class="image-desc"><p>'.$image['post_title'].' '.$image['post_excerpt'].'</p></div> </div> </li>'; } ?> <?php endwhile; ?> <?php endif; ?>
-
I think the easiest way to do this would be to use WP_QUERY to build your loop. That way you can set ‘posts_per_page’ to -1 and avoid paging. You could also use a pre_get_post action, targeted just at whatever view this is on, but I think using WP_QUERY would be simpler.
Please let me know if you need help implementing either of these solutions or need any other help with Pods.
thank you. how would it right coded, because its in the single.php template? dont forget, i want only to loop the several post and its attachements.
This should work if you set the post_type name to your Pod name and is simpler than I suggested before:
<?php $args = array( 'post_type' => 'POD_NAME', 'posts_per_page' => -1, ); $posts = get_posts( $args ); foreach ( $post as $post ) { $images = get_post_meta( $post->ID, 'works' ); foreach ( $images as $image ) { $testtitel = get_the_title(); echo '<li class="nav3"><a title="'.$testtitel.' - '.$image['post_title'].'" class="thumb" href="'.$image['guid'].'">'.pods_image( $image, 'works-navi' ).'</a> <div class="caption"> <div class="image-desc"><p>'.$image['post_title'].' '.$image['post_excerpt'].'</p></div> </div> </li>'; } //endforeach $images } //endforeach $posts ?>
thank you but it doesnt work. no post is shown.
Should be
foreach ( $posts as $post ) {
on ~L7 sorry about that. I’m pretty sure that is why it’s not working.To test that it’s getting posts properly, you should var_dump $posts. That should give you an object for each post.
now it works, but all posts are shown. but i want to show only a single post type with all its attachments.
Oh I see, that’s even easier.
global $post; $images = get_post_meta( $post->ID, 'works' ); foreach ( $images as $image ) { $testtitel = get_the_title(); echo '<li class="nav3"><a title="'.$testtitel.' - '.$image['post_title'].'" class="thumb" href="'.$image['guid'].'">'.pods_image( $image, 'works-navi' ).'</a> <div class="caption"> <div class="image-desc"><p>'.$image['post_title'].' '.$image['post_excerpt'].'</p></div> </div> </li>'; } //endforeach $images
now it works, but attachments are paginated.
here is my actually code:
<?php $args = array( 'post_type' => 'kuenstler', 'posts_per_page' => -1, ); $posts = get_posts( $args ); global $post; $images = get_post_meta( $post->ID, 'arbeiten' ); foreach ( $images as $image ) { $testtitel = get_the_title(); echo '<li class="nav3"><a title="'.$testtitel.' - '.$image['post_title'].'" href="'.$image['guid'].'">'.pods_image( $image, 'arbeiten-navi' ).'</a> <div class="caption"> <div class="image-desc"><p>'.$image['post_title'].' '.$image['post_excerpt'].'</p></div> </div> '; } //endforeach $images ?>
That shouldn’t cause pagination. Another thing to try would be
posts_per_page' => 999999
posts_per_page parameter is for my post type “kuenstler”, but not for the attachments.
I’m very confused. Are you saying that the $images foreach loop is paginating? Can you show me your complete template code please?
yeah, i said it in my first post – that is my problem: I do not want paginate the attached images of Pods “Kuenstler”! ??
<?php /** Künstler Einzelansicht */ get_header(); ?> <div id="sidebar"> <?php get_sidebar(); ?> </div> <div id="content"> <div id="pfeil"> <?php /*Navigationspfeile LINKS*/previous_post_link_plus( array('tooltip' => false/*%title*/,'loop' => true,'order_by' => 'post_title','format' => '%link','link' => '<img alt="previous" src="https://cernyundpartner.de/wp-content/themes/cerny/img/pfeil_links.jpg" />','order' => 'ASC') ); ?> </div> <div id="content_inside"> <div id="content_head"> <div class ="balken_red"> </div> <div class="headline"> <p> <?php while ( have_posts() ) : the_post(); ?> <?php //Beginn Splitten vom Title - getrennt durch einen Punkt?> <?php $data = get_the_title(); list($nachname, $vorname) = explode(".", $data); echo $vorname.'<br>' ; echo $nachname ; ?> <?php endwhile; ?> <?php //ENDE Splitten vom Title - getrennt durch einen Punkt ?> </p> </div> <div class="headline"> </div> <div id="headline_space"> <div id="pfeil2" style="margin-right: -25px;"> <?php /*Navigationspfeile RECHTS*/next_post_link_plus( array('tooltip' => false/*%title*/,'loop' => true, 'order_by' => 'post_title', 'format' => '%link', 'link' => '<img alt="next" src="https://cernyundpartner.de/wp-content/themes/cerny/img/pfeil_rechts.jpg" />', 'order' => 'ASC') ); ?> </div> </div> <div class ="balken_red"> </div> </div> <div class="linieoben"> </div> <div id="tabs" class="text"> <?php //pods_Auslesen aller Felder if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?> <?php $homepage = get_post_meta($post->ID, 'homepage', true); ?> <?php $vita = get_post_meta($post->ID, 'vita', true); ?> <?php $ausstellungen = get_post_meta($post->ID, 'ausstellungen', true); ?> <?php $texte = get_post_meta($post->ID, 'texte', true); ?> <?php $images = get_post_meta($post->ID, 'arbeiten', true); ?> <?php $buecher = get_post_meta($post->ID, 'buecher', true); ?> <?php endwhile; ?> <?php endif; ?> <ul id="singlenavi"> <?php if(get_post_meta($post->ID, 'arbeiten', true) != '') : ?> <li style="float: left;margin-right: 10px;"><a href="#tabs-1">»Arbeiten</a></li> <?php endif; ?> <?php if((get_post_meta($post->ID, 'vita', true) != '') || (get_post_meta($post->ID, 'ausstellungen', true) != '')) : ?> <li style="float: left;margin-right: 10px;"><a href="#tabs-2">»Vita+Ausstellungen</a></li> <?php endif; ?> <?php if(get_post_meta($post->ID, 'texte', true) != '') : ?> <li style="float: left;margin-right: 10px;"><a href="#tabs-3">»Texte</a></li> <?php endif; ?> <?php if(get_post_meta($post->ID, 'buecher', true) != '') : ?> <li style="float: left;margin-right: 10px;"><a href="#tabs-4">»Bücher</a></li> <?php endif; ?> </ul> <?php if(get_post_meta($post->ID, 'homepage', true) != '') : ?> <li style="list-style: none;"><a style="color:#58585A" href="https://<?php echo $homepage; ?>" target="_blank">»<?php echo $homepage; ?></a></li> <?php endif; ?> <div class="linieunten"> </div> <div id="tabs-1"> <div id="galerie2"> <div> <div id="gallery" class="content" style="margin-top: -13px;"> <div id="controls" class="controls"> </div> <div class="slideshow-container" style="height: 599px;"> <div id="slideshow" class="slideshow"> </div> </div> </div> <div style="clear: both;"> </div> </div> </div> <div id="underline"> <div id="caption" class="caption-container"></div> </div> <div id="gal_navi"> <div style="float: left;margin-right: 10px;"> <div id="thumbs" class="navigation"> <ul class="thumbs noscript"> <?php //pods_image anzeigen lassen --> navi unten $args = array( 'post_type' => 'kuenstler', 'posts_per_page' => -1, ); $posts = get_posts( $args ); global $post; $images = get_post_meta( $post->ID, 'arbeiten' ); foreach ( $images as $image ) { $testtitel = get_the_title(); echo '<li class="nav3"><a title="'.$testtitel.' - '.$image['post_title'].'" class="thumb" href="'.$image['guid'].'">'.pods_image( $image, 'arbeiten-navi' ).'</a> <div class="caption"> <div class="image-desc"><p>'.$image['post_title'].' '.$image['post_excerpt'].'</p></div> </div> </li>'; } ?> </ul> </div> </div> </div> </div> <div class="clear"> </div> <div id="tabs-2"> <?php //pods_Vita if ($vita != '') : ?><h1>Vita</h1><?php endif; ?> <?php echo $vita; ?> <?php //pods_Ausstellungen if ($ausstellungen != '') : ?><h1>Ausstellungen</h1><?php endif; ?> <?php echo $ausstellungen; ?> </div> <div id="tabs-3"> <?php //pods_Texte echo $texte; ?> </div> <div id="tabs-4"> <?php //pods_Bücher ?> <?php echo $buecher; ?> </div> </div> </div> </div> <div class="clear"> </div> <script type="text/javascript"> // We only want these styles applied when javascript is enabled $('div.navigation').css({'width' : '698px', 'float' : 'left'}); $('div.content').css('display', 'block'); // Initially set opacity on thumbs and add // additional styling for hover effect on thumbs //var onMouseOutOpacity = 0.67; //$('#thumbs ul.thumbs li').css('opacity', onMouseOutOpacity) // .hover( // function () { // $(this).not('.selected').fadeTo('fast', 1.0); // }, // function () { // $(this).not('.selected').fadeTo('fast', onMouseOutOpacity); // } // ); // ENDE additional styling for hover effect on thumbs $(document).ready(function() { // Initialize Minimal Galleriffic Gallery $('#thumbs').galleriffic({ imageContainerSel: '#slideshow', controlsContainerSel: '#controls', captionContainerSel: '#caption', }); }); </script> <?php get_footer(); ?>
I don’t see where in the $images foreach loop you would be getting pagination. Can you point me to where that pagination is being generated for images?
I did notice that you still have this bit, which isn’t needed, in there:
$args = array( 'post_type' => 'kuenstler', 'posts_per_page' => -1, ); $posts = get_posts( $args );
here is a link to one single archive of post type “kuenstler”.
your second point: do you mean, that i can delete these args?
thank you for your help. ??
You don’t need that get_posts() at all. It’s not doing anything.
It seems to me as if Galleriffic is creating the pagination. Just glancing at their docs, it looks like that if you set
numThumbs
to -1 or 9999 that should be able to prevent pagination.
- The topic ‘how set up the number of attachments’ is closed to new replies.