WordPress show child of a category with posts related
Order of category and post come from “Intuitive Custom Post Order” plugin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
<section id="section_album_photo" class="fw-main-row "> <div class="fw-main-row-bg" style=" "></div> <div class="fw-main-row-overlay has-color"></div> <div style="" class="fw-container "> <div class="fw-row"> <div class="fw-col-xs-12 "> <div class="textblock-shortcode"><h2><?php echo $cat->name; ?></h2></div> </div> </div> <?php $args = array( 'post_type' => 'galerie_photo', 'cat' => $cat->term_id, 'posts_per_page' => -1, ); $counter = 1; $loop = new WP_Query( $args ); $count_loop = $loop->post_count; while ( $loop->have_posts() ) : $loop->the_post(); //$photo_id = get_the_id(); $image = get_field('galerie_image'); ?> <?php if ($counter == 1) { ?> <div class="fw-row"> <?php } ?> <div class="fw-col-xs-12 fw-col-sm-3 "> <div class="textblock-shortcode"> <?php if( get_field('galerie_credits') ){ $galerie_credits = '<small align="center">Photo par '.get_field('galerie_credits').'</small>'; }else{ $galerie_credits = ''; } ?> <?php if( get_field('galerie_web_uniquement') == 1) { $galerie_web_uniquement = '<small align="center">web uniquement</small>'; }else{ $galerie_web_uniquement = ''; } ?> <?php if( get_field('galerie_titre_visible') ){ echo "<h3>".get_field('galerie_titre_visible')."</h3>"; } ?> <?php echo do_shortcode( '[restrict userlevel="subscriber"] <a href="'.$image["url"].'" rel="attachment wp-att-3974" target="_blank"> [/restrict]' ); ?> <img src="<?php echo $image['sizes']['thumbnail']; ?>" width="150" height="150" class="alignnone size-thumbnail"> <?php echo do_shortcode( '[restrict userlevel="subscriber"] </a>'.$galerie_credits.''.$galerie_web_uniquement.'[/restrict]' ); ?> </div> </div> <?php //echo $wp_query->post_count; if (($counter % 4 == 0) && ($counter != $count_loop)){ ?> </div> <div class="fw-row"> <div class="fw-col-xs-12 "> <div class="fw-divider-space" style="padding-top: 50px;"></div> </div> </div> <div class="fw-row"> <?php } $counter +=1; ?> <?php endwhile; ?> </div> </div> </section> |