Skip to content

Instantly share code, notes, and snippets.

@shumbo
Created February 18, 2017 15:20
Show Gist options
  • Save shumbo/47735eafdaf2ca3004cd5be1393be8cf to your computer and use it in GitHub Desktop.
Save shumbo/47735eafdaf2ca3004cd5be1393be8cf to your computer and use it in GitHub Desktop.
<?php while (have_posts()) : the_post(); ?>
<?php $skip_sidebar = get_post_meta( $post->ID, 'skip_sidebar', true ); ?>
<div class="col-md-12">
<article id="post-<?php the_ID(); ?>" <?php post_class( 'row' ); ?> itemscope itemtype="http://schema.org/Article">
<header class="entry-header">
<?php the_title( '<h1 class="entry-title" itemprop="headline">', '</h1>' ); ?>
<?php if ( function_exists( 'wedocs_get_option' ) && wedocs_get_option( 'print', 'wedocs_settings', 'on' ) == 'on' ): ?>
<a href="#" class="wedocs-print-article wedocs-hide-print wedocs-hide-mobile" title="<?php echo esc_attr( __( 'Print this article', 'wedocs' ) ); ?>"><i class="wedocs-icon wedocs-icon-print"></i></a>
<?php endif; ?>
</header>
<div class="entry-content" itemprop="articleBody">
<?php the_content(); ?>
<?php
$my_wp_query = new WP_Query(); // set up Wp Query
$children = $my_wp_query->query( array(
'post_type' => $post->post_type,
'post_parent' => $post->ID,
'nopaging' => 'true',
'orderby' => 'menu_order',
'order' => 'ASC'
) ); // Get the children in order
if($children){ // If this post has children
echo '<div class="article-child well">';
echo '<h3>' . __( 'Articles', 'wedocs' ) . '</h3>';
echo '<ul>';
foreach($children as $child){
// Generate list of chilren. Change as you like. $child is the post object of the child'
echo '<li>';
$link = get_permalink($child);
$title = $child->post_title;
echo "<p><a href='$link'>$title</a></p>";
if($child->post_excerpt == ''){
// If post_excerpt is empty generate excerption manually.
$trimed = wp_trim_words($child->post_content, apply_filters( 'excerpt_length', 55 ), apply_filters( 'excerpt_more', ' ' . '[&hellip;]' ));
if($trimed){ // If generated successfully, show.
echo $trimed;
}else{ // If still empty, nothing to show as excerpt
}
}else{
// If post_excerpt available, just echo that.
echo $child->post_excerpt;
}
echo '</li>';
}
echo '</ul>';
echo '</div>';
}
?>
</div>
<footer class="entry-footer wedocs-entry-footer">
<?php if ( function_exists( 'wedocs_get_option' ) && wedocs_get_option( 'email', 'wedocs_settings', 'on' ) == 'on' ): ?>
<span class="wedocs-help-link wedocs-hide-print wedocs-hide-mobile">
<i class="wedocs-icon wedocs-icon-envelope"></i>
<?php printf( '%s <a id="wedocs-stuck-modal" href="%s">%s</a>', __( 'Still stuck?', 'wedocs' ), '#', __( 'How can we help?', 'wedocs' ) ); ?>
</span>
<?php endif; ?>
<div class="wedocs-article-author" itemprop="author" itemscope itemtype="https://schema.org/Person">
<meta itemprop="name" content="<?php echo get_the_author(); ?>" />
<meta itemprop="url" content="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>" />
</div>
<meta itemprop="datePublished" content="<?php echo get_the_time( 'c' ); ?>"/>
<time itemprop="dateModified" datetime="<?php echo esc_attr( get_the_modified_date( 'c' ) ); ?>"><?php printf( __( 'Updated on %s', 'wedocs' ), get_the_modified_date() ); ?></time>
</footer>
<?php
if ( $skip_sidebar != 'yes' ) {
if ( function_exists( 'wedocs_doc_nav' ) ) {
wedocs_doc_nav();
}
if ( function_exists( 'wedocs_get_template_part' ) && function_exists( 'wedocs_get_option' ) ) {
if ( wedocs_get_option( 'helpful', 'wedocs_settings', 'on' ) == 'on' ) {
wedocs_get_template_part( 'content', 'feedback' );
}
if ( wedocs_get_option( 'email', 'wedocs_settings', 'on' ) == 'on' ) {
wedocs_get_template_part( 'content', 'modal' );
}
}
}
?>
</article>
</div><!-- .col-md-# -->
<?php endwhile; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment