0

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

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. :-)

| 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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