Created
September 17, 2014 20:08
-
-
Save michaelbrazell/d3dc4e0e8b60398a70e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The template used for displaying page content in page.php | |
* | |
* @package doc | |
*/ | |
?> | |
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> | |
<header class="entry-header"> | |
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?> | |
</header><!-- .entry-header --> | |
<div class="entry-content"> | |
<?php the_content(); ?> | |
<?php | |
//for each category, show 5 posts | |
$cat_args=array( | |
'orderby' => 'name', | |
'order' => 'ASC' | |
); | |
$categories=get_categories($cat_args); | |
foreach($categories as $category) { | |
$args=array( | |
'showposts' => 5, | |
'category__in' => array($category->term_id), | |
'caller_get_posts'=>1 | |
); | |
$posts=get_posts($args); | |
if ($posts) { | |
$args=array( | |
'orderby' => 'title', | |
'order' => 'ASC', | |
'post_status' => 'published' | |
); | |
?> | |
<div class="category-box"><div class="category-title"><h3><a href="<?php echo get_category_link( $category->term_id ) ?>" title="<?php echo sprintf( __( "View all posts in %s" ), $category->name ) ?>"><?php echo $category->name ?></a></h3></div> | |
<div class="category-posts"> | |
<ul> | |
<?php | |
$count_posts = 0; | |
foreach($posts as $post) { | |
$count_posts = $count_posts+1; | |
setup_postdata($post); ?> | |
<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a> | |
<?php } // foreach($posts | |
?> | |
</ul> | |
<p>Total <a href="<?php echo get_category_link( $category->term_id ) ?>" title="<?php echo sprintf( __( "View all posts in %s" ), $category->name ) ?>"><?php echo $category->name ?></a>: <?php echo $count_posts; ?></p> | |
</div> | |
</div> | |
<?php | |
} // if ($posts | |
} // foreach($categories | |
?> | |
<?php | |
wp_link_pages( array( | |
'before' => '<div class="page-links">' . __( 'Pages:', 'doc' ), | |
'after' => '</div>', | |
) ); | |
?> | |
</div><!-- .entry-content --> | |
<footer class="entry-footer"> | |
<?php edit_post_link( __( 'Edit', 'doc' ), '<span class="edit-link">', '</span>' ); ?> | |
</footer><!-- .entry-footer --> | |
</article><!-- #post-## --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment