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!

9 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

    Mathias Vagni Reply:

    I think what is making it not work for you is the space between the first “<” and “?php”. Delete the space.

    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

  5. Joel says:

    Great tip. I just wish you attached screenshots to the article. It’s difficult to imagine how these subtitles look like when coupled with WordPress blog titles if you’ve been seeing just titles since the blogging platform was launched.

    Reply

  6. Joel says:

    Oh, duh! My bad. There they are. Can the subtitles appear just below the title on the main page, before the jump? It looks out of place when it’s below the date, appearing more like a blurb than a subtitle.

    Reply

  7. […] was looking to add subtitles to my posts. I found the answer over at Clever Carrot: In your WordPress editor simply add « subtitle » in the custom name field […]

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.