Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Template Name: News Template
- * Description: Used as a page template to show page contents, followed by a loop through
- * each non-empty category that has at least 1 published post and displays the latest posts'
- * content and featured image with a link to the category archive page below the list.
- */
- add_action( 'genesis_entry_content', 'sk_custom_content' );
- function sk_custom_content() {
- $categories = get_categories();
- echo '<div class="category-loop">';
- foreach ( $categories as $category ) {
- echo '<div class="category-item">';
- // Category title
- echo '<h3 class="category-title">' . $category->name . '</h3>';
- $args = array(
- 'cat' => $category->term_id,
- 'posts_per_page' => 3
- );
- // The Query
- $the_query = new WP_Query( $args );
- while ( $the_query->have_posts() ) {
- $the_query->the_post();
- echo '<div class="cat-listing ' . $category->slug . '-item">';
- echo '<h4>'. get_the_title() . '</h4>';
- echo '<p class="cat-date entry-meta">';
- echo the_date();
- echo '</p>';
- if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
- the_post_thumbnail( 'full', array( 'class' => 'alignright' ) );
- }
- // echo the_content();
- echo the_excerpt();
- if( function_exists( 'social_warfare' ) ):
- social_warfare();
- endif;
- echo '</div>';
- }
- echo '<a class="category-more" href="' . get_category_link( $category->term_id ) . '">More from the "' . $category->name . '" category …</a>';
- /* Restore original Post Data */
- wp_reset_postdata();
- echo '</div><!-- .category-item -->';
- }
- echo '</div>';
- }
- genesis();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement