Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * The template for displaying Author's pages.
- */
- // GET CURRENT AUTHOR
- if (get_query_var('author')) {
- global $wp_query;
- $curauth = $wp_query->get_queried_object();
- }
- // AUTHOR LINK
- $auth_link = esc_url(get_author_posts_url(false, $curauth->user_nicename));
- // GET HEADER
- get_header();
- ?>
- <div id="primary" class="content-area">
- <main id="main" class="site-main" role="main">
- <div class="container">
- <div class="row">
- <div class="col-12 col-md-9 p-1 bg-white pt-2 mt-2 container-fluid">
- <div class="row-fluid">
- <!-- Posts -->
- <div class="latest-posts">
- <?php
- $args = array(
- 'author' => $curauth->ID,
- 'post_type' => array('song', 'poem'), // get all post types
- 'posts_per_page' => 10 // // get 10 posts from all post types
- );
- query_posts($args);
- if (have_posts()) : while (have_posts()) : the_post();
- ?>
- <!-- single post title, author -->
- <div class="post-title">
- <a href="<?php echo esc_url(get_permalink()); ?>">
- <h4 class="text-title">
- <?php the_title(); ?>
- </h4>
- </a>
- <span>Post by <?php echo the_author_meta('display_name'); ?></span>
- </div>
- <?php
- endwhile; // end loop
- wp_reset_postdata(); // reset query
- endif;
- ?>
- </div>
- </div>
- <!-- LINK TO ALL POSTS -->
- <?php
- // IF TOTAL POSTS ARE MORE THAN 10; SHOW CURRENT AUTHORS ALL POSTS IN ARCHIVE PAGE
- if (($total = count_user_posts($curauth->ID, array('song', 'poem'))) > 10) {
- echo '<a href="' . $auth_link . '?post_type[]=song&post_type[]=poem">View All</a>';
- }
- ?>
- </div>
- </div><!-- #primary -->
- </div>
- </main><!-- #main -->
- </div>
- <?php
- get_footer();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement