Guest User

Untitled

a guest
Dec 5th, 2016
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.56 KB | None | 0 0
  1. <?php
  2. /**
  3.  * The main template file.
  4.  *
  5.  * This is the most generic template file in a WordPress theme
  6.  * and one of the two required files for a theme (the other being style.css).
  7.  * It is used to display a page when nothing more specific matches a query.
  8.  * E.g., it puts together the home page when no home.php file exists.
  9.  * Learn more: http://codex.wordpress.org/Template_Hierarchy
  10.  *
  11.  * @package _s
  12.  */
  13.  
  14. get_header(); ?>
  15.  
  16. <div id="primary" class="content-area col-md-8">
  17.   <main id="main" class="site-main" role="main">
  18.  
  19.     <div class="row">
  20.       <div class="gamecam col-lg-12">
  21.         <h3>Game Cam Photos</h3>
  22.  
  23.         <?php
  24.     $args = array( 'post_type' => 'attachment', 'posts_per_page' => 3, 'post_mime_type' => 'image', 'order' => DESC, 'post_status' =>'any', 'post_parent' => $post->ID );
  25.     $query = new WP_Query( array( 'category_name' => 'game-cam', 'posts_per_page' => 1 ) );
  26.     ?>
  27.  
  28.         <?php while ( $query->have_posts() ) : $query->the_post(); ?>
  29.  
  30.           <?php
  31.  
  32.           $images = get_posts( $args );
  33.           if ( $images ) {
  34.               foreach ( $images as $image ) { ?>
  35.             <div class="col-md-4 col-sm-6"><div class="gamecam-pic"><a href="<?php echo wp_get_attachment_url( $image->ID , 'medium' ); ?>" rel="lightbox"><?php echo wp_get_attachment_image( $image->ID, 'gamecam img-responsive' ); ?></a></div></div>
  36.           <?php   }
  37.     } ?>
  38.  
  39.         <?php
  40.     // Reset Query
  41.         wp_reset_postdata();
  42.     endwhile;
  43.         ?>
  44.  
  45.  
  46.         <div class="col-md-12"><a href="<?php echo get_permalink(); ?>"><h4>View All Game Pics</h4></a></div>
  47.       </div><!-- end .gamecam -->
  48.  
  49.     </div><!-- end .row -->
  50.     <div class="row">
  51.       <div class="col-lg-12">
  52.         <h3 class="latest-news">Latest News</h3>
  53.       </div>
  54.     </div>
  55.  
  56.     <?php if ( have_posts() ) : ?>
  57.  
  58.       <?php /* Start the Loop */ ?>
  59.       <?php while ( have_posts() ) : the_post(); ?>
  60.  
  61.         <?php
  62.  
  63.         /*
  64.          * Include the Post-Format-specific template for the content.
  65.          * If you want to override this in a child theme, then include a file
  66.          * called content-___.php (where ___ is the Post Format name) and that will be used instead.
  67.          */
  68.         get_template_part( 'template-parts/content', get_post_format() );
  69.         ?>
  70.  
  71.       <?php endwhile; ?>
  72.  
  73.       <?php the_posts_navigation(); ?>
  74.  
  75.     <?php else : ?>
  76.  
  77.       <?php get_template_part( 'template-parts/content', 'none' ); ?>
  78.  
  79.     <?php endif; ?>
  80.  
  81.   </main><!-- #main -->
  82. </div><!-- #primary -->
  83.  
  84. <?php get_sidebar(); ?>
  85. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment