Last active
November 1, 2020 18:23
-
-
Save alfintechcomputer/7df12f8df4439dc5e533913a77624d01 to your computer and use it in GitHub Desktop.
WordPress Excerpts adding ‘Read More’ links to […]
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 | |
get_header(); | |
if ( have_posts() ) : | |
while ( have_posts() ) : the_post(); ?> | |
<article class="post"> | |
<h2><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h2> | |
<p class="post-meta"><?php the_time( 'F jS, Y' ); ?> | <a | |
href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ); ?>"><?php the_author(); ?></a> | |
| <?php | |
$categories = get_the_category(); | |
$comma = ', '; | |
$output = ''; | |
if ( $categories ) { | |
foreach ( $categories as $category ) { | |
$output .= '<a href="' . get_category_link( $category->term_id ) . '">' . $category->cat_name . '</a>' . $comma; | |
} | |
echo trim( $output, $comma ); | |
} ?> | |
</p> | |
<p> | |
<?php echo get_the_excerpt() ?> | |
<a href="<?php the_permalink() ?>">Read more »</a> | |
</p> | |
</article> | |
<?php endwhile; | |
else : | |
echo '<p>There are no posts!</p>'; | |
endif; | |
get_footer(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment