Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to add my custom fields after the page title when you view it on the site. How do I do this?

PAGE TITLE [CUSTOM FIELDS HERE]

PAGE CONTENT

share|improve this question

1 Answer 1

Use get_post_meta() in the theme template you want to modify. Like so...

<h1>If This Were Your Page Title</h1>
<?php echo get_post_meta(get_the_ID(), 'Your Custom Field Name', true); ?>

Easy peasy. :-)

share|improve this answer
    
I wish it was, but I'm a dope. Can i add my meta to my theme's page.php? and Where? This is some of the code that's in the file: <?php global $theme; get_header();?> <div id="main"> <?php $theme->hook('main_before');?> <div id="content"> <?php $theme->hook('content_before'); ?> –  Meaghan Danzy Mar 7 '13 at 17:38
    
Check the link I provided for get_post_meta(), which explains it in detail. You can use the function anywhere, and it just needs a post id, the name of your custom field, and whether you want a value or array (true returns a single value, false returns an array). get_the_ID() can be used in just about any page template file (home.php, index.php, single.php, page.php, etc). –  Matt Van Andel Mar 7 '13 at 18:02
    
can i add the meta after a theme hook? such as title_after? –  Meaghan Danzy Mar 7 '13 at 19:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.