Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Template Name: Categories Table
- */
- # Force full width content
- add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
- # Remove the post content
- remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
- # Add custom post content
- add_action( 'genesis_entry_content', 'sk_do_post_content' );
- /**
- * Outputs custom post content
- *
- * @return void
- */
- function sk_do_post_content() {
- $cat_args = array(
- 'orderby' => 'name',
- // 'parent' => 0
- );
- $categories = get_categories( $cat_args );
- foreach ( $categories as $category ) {
- echo '<div class="category-item">';
- // Category title
- echo '<h2 class="category-title"><a href="' . get_category_link( $category->term_id ) . '">' . $category->name . '</a></h2>';?>
- <table>
- <thead>
- <tr>
- <th>Title</th>
- <th>Author</th>
- <th>Date</th>
- <th>Tags</th>
- <th>Views</th>
- </tr>
- </thead>
- <tbody>
- <?php
- $args = array(
- 'orderby' => 'title',
- 'order' => 'ASC',
- // 'category__in' => array($category->term_id),
- 'cat' => $category->term_id,
- 'posts_per_page' => -1
- );
- // The Query
- $the_query = new WP_Query( $args );
- while ( $the_query->have_posts() ) {
- $the_query->the_post();
- ?>
- <tr>
- <td><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></td>
- <td><?php the_author_link(); ?></td>
- <td><?php the_date(); ?></td>
- <td><?php the_tags(); ?></td>
- <td>No. of Views</td>
- </tr>
- <?php }
- /* Restore original Post Data */
- wp_reset_postdata(); ?>
- </tbody>
- </table>
- <?php
- echo '</div><!-- .category-item -->';
- }
- }
- genesis();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement