Advertisement
MimiDev

the page

Aug 7th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.41 KB | None | 0 0
  1. <?php
  2.  
  3. get_header();
  4. ?>
  5.  
  6. <div id="main-content">
  7.     <div id="mj-main-banner" style="background-image: url('<?php the_field('mj_banner_image'); ?>');"></div>
  8.     <div class="container">
  9.         <div id="content-area" class="clearfix">
  10.             <?php while ( have_posts() ) : the_post(); ?>
  11.                 <article id="post-<?php the_ID(); ?>">
  12.                    <div class="et_post_meta_wrapper">
  13.                     <h2><?php the_field('trip_title'); ?></h2> <!-- ACF variable -->
  14.                    </div> <!-- .et_post_meta_wrapper -->
  15.                    
  16.                     <div class="entry-content">
  17.                        <?php
  18.                            the_field('details_about_this_trip');
  19.                        ?>
  20.                     </div> <!-- .entry-content -->
  21.                 </article>
  22.          <?php endwhile; ?>
  23.       </div> <!-- #content-area -->
  24.      
  25.       <div id="blog-grid-minor">
  26.             <h3>Blog Posts for this trip</h3>
  27.  
  28.             <!-- Search all posts for those with the category for this trip -->
  29.             <?php      
  30.                 $args = array(
  31.                     'post_type' => 'post',
  32.                     'posts_per_page' => 6,
  33.                     'order' => 'desc',
  34.                     'orderby' => 'date',
  35.                     'tax_query' => array(
  36.                         array(
  37.                             'taxonomy' => 'category',
  38.                             'field'    => 'slug',
  39.                             'terms'    => get_field('category_to_display'), // category from the custom field
  40.                         ),
  41.                     ),
  42.                 );
  43.                
  44.                 // Get current page and append to custom query parameters array
  45.                 $args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
  46.  
  47.                 $the_query = new WP_Query( $args );
  48.            
  49.             // Pagination fix
  50.             $temp_query = $wp_query;
  51.                 $wp_query   = NULL;
  52.                 $wp_query   = $the_query;
  53.          ?>
  54.  
  55.             <!-- This line is here for purposes of error checking during process of getting pagination to work -->
  56.             <?php
  57.                 echo "<p style='color: blue;'><strong>";
  58.                 echo "The total number of pages to display is: " . $the_query->max_num_pages;
  59.                 echo "</strong></p>";
  60.             ?>
  61.          
  62.          <div id="fwd-blog-grid">
  63.                 <?php if ( $the_query->have_posts() ) : ?>
  64.                     <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
  65.                         <div class="fwd-grid-item">
  66.                             <?php if ( has_post_thumbnail() ) {
  67.                                 the_post_thumbnail();
  68.                             } ?>
  69.                             <h2><a href='<?php the_permalink(); ?>'><?php the_title(); ?></a></h2>
  70.                             <div class="entry-content">
  71.                                 <a href='<?php the_permalink(); ?>'><?php the_excerpt(); ?></a>
  72.                             </div>
  73.                         </div>
  74.                     <?php endwhile; ?>
  75.  
  76.                     <?php
  77.                         wp_reset_postdata();
  78.                        
  79.                         echo "<div style='clear: both;'>";
  80.                             //wp_pagenavi( array( 'query' => $the_query ) );
  81.                             echo "<div style='float: right;'>";
  82.                                 next_posts_link( '&laquo; Newer Posts', $the_query->max_num_pages );
  83.                             echo "</div>";
  84.                            
  85.                             echo "<div style='float: left;'>";
  86.                                 previous_posts_link( 'Older Posts &raquo;' );
  87.                             echo "</div>";
  88.                         echo "</div>";
  89.                        
  90.                         // Reset main query object
  91.                         $wp_query = NULL;
  92.                         $wp_query = $temp_query;
  93.                     ?>
  94.                  
  95.              <?php else:  ?>
  96.                  <p style="text-align: center;">There are no blog posts to display. Mianne is still sorting this bit of code out! :) </p>
  97.                  <p style="text-align: center;">We might be out of signal range, but will be sure to add a blog post as soon as we can.</p>
  98.              <?php endif; ?>
  99.              
  100.           </div>
  101.         </div> <!-- #blog-grid-minor" -->
  102.     </div> <!-- .container -->
  103. </div> <!-- #main-content -->
  104.  
  105. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement