Adding a subtitle, based upon a custom field

Hi,

I've created a custom field called subtitle... and would like to add a line of code to my page.php file so that it displays underneath the title...

but am getting confused about what to put in the code. This is what I came up with but it's not working.

<h2 $post->ID 'subtitle'> </h2>

Many thanks for your help!

Andrew

  • drmike
    • DEV MAN’s Mascot

    Maybe...

    <h2><?php $key="subtitle"; echo get_post_meta($post->ID, $key, true); ?></h2>

    edit: I just noticed in your example you have the subtitle bit within the beginning h2 tag instead of between the h2 tags. Are you trying to display the contents of the subtitle field to the visitor or is it some sort of id or class tag?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.