Advertisement
bcworkz

content-child-page.php

Jun 14th, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.17 KB | None | 0 0
  1. <?php
  2. /**
  3.  * This template is used to display child page content
  4.  *
  5.  * @package Child of Baskerville 2
  6.  */
  7. ?>
  8. <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  9.  
  10.     <?php
  11.     /**
  12.      * Post Title
  13.      */
  14.  
  15.     echo '<span class="child-title">';
  16.         the_title( $before_title, $after_title );
  17.     echo '</span>';
  18.  
  19.     /**
  20.      * Post Thumbnail
  21.      */
  22.     if ( baskerville_2_has_post_thumbnail() ) { ?>
  23.         <div class="featured-media">
  24.             <?php if ( ! is_single() ) { ?>
  25.                 <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">
  26.             <?php }
  27.                 the_post_thumbnail( 'baskerville-2-post-image' );
  28.             if ( ! is_single() ) { ?>
  29.                 </a>
  30.             <?php } ?>
  31.         </div> <!-- /featured-media -->
  32.     <?php }
  33.  
  34.     /**
  35.      * Child Page Excerpts
  36.      */
  37.     $args = array(
  38.         'post_type' => 'page',
  39.         'post_parent' => get_the_ID()
  40.     );
  41.     // get child pages
  42.     $query = new WP_Query( $args );
  43.     if ( $query->have_posts() ) {
  44.         echo '<div class="posts-masonry">';
  45.         // loop through the query results
  46.         while ( $query->have_posts() ) {
  47.             $query->the_post();
  48.             echo '<div class="page-container">';
  49.  
  50.                 /**
  51.                  * Page Title and Category Link
  52.                  */
  53.                 $before_title = '<header class="post-header"><h1 class="post-title entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">';
  54.                 $cat = get_the_category()[0];
  55.                 $link = get_category_link( $cat->term_id );
  56.                 $cat_link = "<div class=\"category {$cat->slug}\"><a href=\"$link\">{$cat->name}</a></div>\n";
  57.                 $after_title = "</a></h1>$cat_link</header>";
  58.                 the_title( $before_title, $after_title );
  59.  
  60.                 /**  
  61.                  * Post Thumbnail
  62.                  */
  63.                 if ( baskerville_2_has_post_thumbnail() ) { ?>
  64.                     <div class="featured-media">
  65.                         <?php if ( ! is_single() ) { ?>
  66.                             <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">
  67.                         <?php }
  68.                             the_post_thumbnail( 'baskerville-2-post-image' );
  69.                         if ( ! is_single() ) { ?>
  70.                             </a>
  71.                         <?php } ?>
  72.                     </div> <!-- /featured-media -->
  73.                 <?php }
  74.  
  75.                 /**
  76.                  * Page Excerpt
  77.                  */ ?>
  78.                     <div class="post-content clear">
  79.                         <?php
  80.                         echo get_more_excerpt();
  81.                         ?>
  82.                     </div><!--/.post-content-->
  83.  
  84.                 <div class="clear"></div>
  85.                 <?php
  86.  
  87.             echo '</div><!-- /.page-container -->';
  88.  
  89.         }
  90.         echo '</div><!-- .posts-masonry -->';
  91.     }
  92.     // Restore original post data.
  93.     wp_reset_postdata();
  94.     //remove_filter( 'the_content', 'get_more_excerpt', 0 );
  95.  
  96.     wp_link_pages();
  97.  
  98.     /**
  99.      * Post Meta
  100.      */
  101.     if ( is_single() ) { ?>
  102.  
  103.         <footer class="post-meta-container clear">
  104.             <?php baskerville_2_author_bio(); ?>
  105.  
  106.             <div class="post-meta clear">
  107.                 <?php baskerville_2_single_post_meta(); ?>
  108.                 <?php the_post_navigation(); ?>
  109.                 <?php edit_post_link(
  110.                     sprintf(
  111.                         /* translators: %1$s: Pencil icon, %2$s: Name of current post */
  112.                         esc_html__( '%1$s Edit %2$s', 'baskerville-2' ),
  113.                         '<i class="fa fa-pencil-square-o"></i>',
  114.                         the_title( '<span class="screen-reader-text">"', '"</span>', false )
  115.                     ),
  116.                     '<span class="edit-link">',
  117.                     '</span>'
  118.                 ); ?>
  119.             </div>
  120.         </footer> <!-- /post-meta-container -->
  121.         <?php comments_template( '', true );
  122.  
  123.     } else {
  124.         baskerville_2_post_meta();
  125.     } ?>
  126.  
  127. </article> <!-- /post-## -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement