Customize WordPress’s “Continue Reading” Link Using Hooks

featimgWordPress is today’s best content management and blogging software. As a matter of fact, it powers this website and many of our clients’ websites. WordPress has many neat functionalities and plugins, which is why so many major websites use WordPress to serve millions of Internet users every day.

There’s no doubt that you will be impressed by a well-designed and well-developed WordPress website. You may even think you should have one too!

After Installation

When you first install WordPress, you may be disappointed by the template provided. It really doesn’t offer much in terms of design. However, that is part of what makes WordPress truly great. Plugins allow you to develop a site that is unique to the needs of your business and your audience. It has an unlimited capacity to meet these needs. Plugins can be added, removed, or improved with widgets as needs change.

There are more than twenty thousand plugins available for WordPress. Unfortunately, however, many of the plugins aren’t maintained, which makes them ultimately useless. The good news is that it only takes ten to twenty plugins to make your WordPress site amazing.

Thousands of WordPress Themes

There are thousands of WordPress themes out there, and certainly some of them will satisfy your needs. However, no theme will do so immediately after installation. More often than not, a theme will need extensive modifications. Everyday people prefer to find a theme and alter it instead of creating one from scratch. On the other hand, professional designers (like our very own Bridget Farrell) prefer to build a theme by themselves because it gives them the power, control and ability to design a theme tailored to their clients’ needs.

img2

The “Continue Reading” Link

When you first install WordPress, all of your posts are listed in their entirety on one page. This makes it difficult for visitors to skim through the different articles you offer. So one of the first things you should do is add the “Continue Reading” link by pressing the “More Link” button and separating the post in wp-admin.

This page arranges posts in such a way that visitors see the title and first paragraph or two of each of your posts, allowing them to get a better idea about what the article is about without having to scroll past the entire article if they’re not interested. However, if they are interested, below the blurb about the article will be a link that visitors can click to continue reading the rest of the article.

And herein lies the beauty of WordPress – a change like this is easy to make. To create this page, for example, all you have to do is split your post in your WordPress Admin Panel by inserting a More tag in the menu for your text editor tool. The logic for making changes in WordPress is similar to this process, no matter what the change is. Once you get the hang of it, you’ll be able to set up your site any way you like and make changes as often as you need to.

The Logic Behind Changing WordPress Sections: Hooks

A hook is a design pattern, specifically a template method pattern, used in software engineering that is supported by WordPress in its most basic logic. While hooks are complicated, they’re integrated into WordPress in such a way that they’re quite simple to use. Basically, a hook is a point within a piece of software where subparts of the software (or plugins, if you’re using WordPress) can be attached to add additional features to the software or override existing ones.

Take anti-virus or firewall software, for example. We all have this kind of protection installed on our computers. When you open a website or download a file, you’re not doing it through the anti-virus software itself, but the program is still able to analyze the data being sent or received.

Hooks are what allow the anti-virus software to scan the data, without the user having to open the software to do so. Operating systems like Windows and Mac OS X allow other programs to be attached to their kernel (using hooks) so that you can extend the features of your computer.

Two Kinds of WordPress Hooks: Action and Filter

WordPress’s hook functionality is divided into two different kinds of hooks: action hooks and filter hooks. Action hooks are used to insert code into the existing code of a program as well as to execute it.

For example:

  • Outputting some HTML to the response buffer
  • Modifying variables’ states
  • Modifying the passed parameters into your hook

Filter hooks work in much the same way, but they can receive a value and return a modified version of it. For example, filter hooks make it possible to display the “Continue Reading” text on your post listing page. The post’s information is given to the filter hook on the post listing page, which returns a “Continue Reading” link to the post’s page where it can be seen and clicked.

Just in case you want to find it, the name of the “Continue Reading” link’s filter hook is: “the_content_more_link”

Where to Place Hooks?

A suitable place for your hooks is in your theme’s folder under functions.php, which can be found here: WordPress-root/wp-content/themes/[theme-name]/functions.php

When you open that file, you will see other hooks that have been defined by the theme designer to extend WordPress functionality. Themes are not just simple HTML, CSS, and Javascript files within WordPress. Themes can run php scripts and can access WordPress features like hooks that extend the functionality of WordPress based on the output requirements of the user. Just remember that changing a theme will disable your hooks since the previous theme’s functions.php will no longer be executed.

Our Continue Reading Hook Code


function new_the_content_more_link( $more ) {
return '
Would you like to Read More?

‘;
}
add_filter( ‘the_content_more_link’, ‘new_the_content_more_link’ );

Adding that code block into your functions.php will change your “Continue Reading” text for all of the posts defined there. For example, we say “Would you like to read more?” and you can write anything, add an image or a button – whatever makes you happy! This is a really simple code block that can be edited with even the tiniest bit of knowledge about scripting.

List of Filter Hooks and Action Hooks

WordPress has a list of hooks on their website.

Filter Hooks
Action Hooks

Hooks and SEO

WordPress has great built-in SEO support but that doesn’t mean we cannot improve it. There are also many additional SEO plugins that you can add to WordPress using hooks. If you understand hooks and read some of our other articles, you can learn a few SEO tricks that aren’t supported by any existing plugins, and apply them to your site. They may even get you ahead of your competitors! For example you may read How to Increase Conversions and Leads on Google AdWords PPC written by our COO Duran Inci and create a plugin for yourself to apply some of the creative ideas in that article.

The Result

Hooks are a powerful feature of WordPress that allow us to extend the functionality of our websites and satisfy the needs of our customers. However, hooks aren’t for everyone. To use them effectively, you must read the WordPress Codex Manual and/or buy a book about them and study hard so you know which hook to use, when to use it, and where to place it.

Once you master WordPress hooks, developing a WordPress plugin is simple if you have adequate programming skills. You can offer to other WordPress users for free, or (if it’s a really great plugin) sell it to them. Just remember that it’s not always about money. Developing a good plugin and providing it to those who need it at no cost will do wonders for your reputation!

You may also want to check out our Microdata Plugin which was developed by our senior programmer, Julian Beaujardin.

Optimum7 uses a variety of techniques to meet the special needs of each of our clients and their audiences. No content management system is able to satisfy more than 99% of people’s needs just with a default installation alone. If you’re looking to improve your website and don’t know where to begin, Contact us today!

Editorial by Lisa Sherman.