How do I auto-apply the "Continue Reading..." link on all posts in Hemlock?
Please note: This FAQ Article is specifically for the Hemlock theme.
The "Continue reading..." link in Hemlock is an excellent tool-- It gives your site's visitors a taste of your posts as well as keeps your homepage tidy & more easily navigable.
By default, you will need to manually insert WordPress's Read More tag into your posts in order to have the "Continue reading..." link appear on your homepage posts. To learn how to go about this, check out: How do I get the "Continue reading" link?
Another option would be to have the theme automatically apply this Read More tag into all of your posts. This is a great option if your site already has a large number of posts that you'd rather not go through and manually apply the Read More tag to. Or, if you'd like the ease of simply not worrying about this extra step for all future posts.
To have the "Continue reading..." link auto-apply to all legacy & future posts, open up the theme's "content.php" file. You can access this file via WP Dashboard > Appearance > Theme Editor > and open the "content.php" file.
On Line 79, you'll see the code for the "Continue reading..." link. It looks like this:
<?php the_content(esc_html__('Continue Reading...', 'hemlock')); ?>
Replace that line of code with the following code instead:
<?php if(is_single()) : ?> <?php the_content(esc_html__('Continue Reading...', 'hemlock')); ?> <?php else : ?> <p><?php the_excerpt(); ?></p> <p><a href="<?php echo get_permalink(); ?>">Continue Reading...</a></p> <?php endif; ?>
Be sure to save the changes to your theme file when you're finished.
Now, to set the number of words each post will display before implementing the Read More tag, we'll need to open up our theme's file titled "functions.php".
Navigate to WP Dashboard > Appearance > Theme Editor > and open up "functions.php".
At the bottom of this document, beginning on Line 272, you'll see the section titled "The Excerpt".
Within this section, there is a line that looks like:
The "19" number value determines the number of words in your post that will display on the homepage before the Read More tag kicks in. You can change this number value to whatever you prefer.
Be sure to save any changes to this file when you're finished.