How to add tag and excerpt fields to WordPress pages

Some WordPress themes don't allow you to add tags and excerpts to pages. This article shows you how you can.

Tags and excerpts are really useful tools for good SEO and search in general. The problem is that sometimes you may find the WordPress theme you are using doesn’t have the option to add tags or excerpts to pages. 

If you find yourself in this kind of situation, there are a few things you could do.

Plugins

“There’s a plugin for that”. Yes, there probably is but I try and stay away from plugins if I can as too many of them can cause problems conflicting with other plugins. The other challenge with plugins is you need to make sure they are regularly updated and compatible with your version of WordPress. 

For example, at the time of writing this, the plugin Add Tags And Category To Page and Post Types is not compatible with WordPress 5.8 and has not been updated for three months. A quick search will give you numerous options so you shouldn’t worry about a shortage of plugins for this kind of functionality.

Code

If you want to get under the hood of WordPress you could add some lines of code to get the same effect. These are called “hooks” which allow you to modify the way your WordPress installation behaves.

This may mean modifying your theme’s functions.php file , the file that contains the code which instructs WordPress on what to load and what functions to run.

The drawback here is that if you edit your theme’s functions file, your changes will be overwritten the next time you update the theme to keep it compatible with WordPress updates and to make it secure. You will need to create a “child theme” to get around that problem. Child themes are great for making customisations to a theme in WordPress without losing your changes when you update the “parent” theme.

Create a child theme

Using FTP (file transfer protocol) software like Filezilla or Cyberduck, connect to your web server. This is the place where your website files are stored. Depending on the level of access you have you might see a folder labelled “htdocs” or “public_html”. Open the folder and look for one labelled “wp-content”, open this one to find “themes” and you should see a folder inside the themes folder with the name of the theme that you wish to make a child theme for.

Create a new folder in the themes folder and label it “yourtheme-child” replacing yourtheme with the name of the theme you are making a child theme for. For example, if the name of the parent theme is “Divi” name your folder “Divi-child”.

Create two text files and upload them into the folder you created. Call the first one “functions.php” and the other “styles.css”. The first file is the one you will modify to add the hooks and the second one is to modify the look of your site by changing styles.

In the functions file copy and paste the code below.

Once you’ve done that you can open up your pages on the WorrdPress administrator panel and you will find you now have the ability to add tags and page excerpts.

 

// add tag support to pages function tags_support_all() { register_taxonomy_for_object_type('post_tag', 'page'); }// ensure all tags are included in queries function tags_support_query($wp_query) { if ($wp_query->get('tag')) $wp_query->set('post_type', 'any'); }// tag hooks add_action('init', 'tags_support_all'); add_action('pre_get_posts', 'tags_support_query'); add_post_type_support( 'page', 'excerpt' );