clever carrot website design

How to Add Subtitles to WordPress

Just copy and paste the code!
In just 3 easy steps you can have attractive subtitles on your WordPress site.
  1. Go to the edit screen for the post or page where you want subtitles.
  2. Under the Custom Fields heading, enter a new custom field name. Type subtitle in the Name field. Type the subtitle text in the Value field. Add the custom field.
  3. Add the below code in your post or page template after the title code (or wherever you want it to appear) and save.
< ?php
{ $subtitle = get_post_meta
($post->ID, 'subtitle', $single = true);
if($subtitle !== '') echo $subtitle;} ?>

Voila!

5 Responses

  1. Anthony says:

    Hey thanks for the post, I think there is an error with the { and the } in the code, once I remove those it works like a charm. I haven’t updated to the latest wordpress yet so it might just be for the older version.

    ID, ‘subtitle’, $single = true);if($subtitle !== ”) echo $subtitle; ?>

    Thanks again :)

    Reply

    Harris Reply:

    That’s odd that there would be an error. For PHP expressions, { is always the beginning and } is the end. Could you email me the code you used? I don’t see it on your site.

    Reply

  2. Mr. Blue says:

    Hi,

    thanks for the tip. However, how do I get the subtitles showing under the title under the next and previous post links when viewing only one post?

    Reply

  3. Simone says:

    How would I go about adding a subtitle to my Page title, so that it in the menu the Page title displays and underneath the subtitle displays?

    Reply

  4. Gaëlle says:

    Tx ! We don’t need any plugin.
    It was just the snippet I was searching for. Custom fields are fantastic.

    Reply

Leave a Reply

contact us with questions
Clever Carrot specializes in web design, search engine optimization, computer consulting, and marketing solutions for small businesses in the New York City area.