Forums

[resolved] Custom fields not showing in page template (7 posts)

  1. Aen
    Member
    Posted 2 years ago #

    What I use in the regular page.php which works fine.

    <?php $page_image = get_post_custom_values('page_image'); ?>
    <?php echo $page_image[0]; ?>

    But when used in a custom page template, the kind you specify with

    /*
    Template Name: HOME
    */

    The custom field does not show up. It is specified in the page that uses the custom page template.

  2. MichaelH
    Volunteer
    Posted 2 years ago #

    Please paste all the code from that 'Home' template file into a pastebin such as wordpress.pastebin.ca, and report the link back here. Maybe someone can spot your problem. Thanks.

  3. Aen
    Member
    Posted 2 years ago #

  4. MichaelH
    Volunteer
    Posted 2 years ago #

    Try

    <?php $page_image = get_post_custom_values('page_image',$posts[0]->ID); ?>
  5. senscore
    Member
    Posted 2 years ago #

    I have the same problem. In single (default) page template this works

    <?php $page_image = get_post_custom_values('page_image',$posts[0]->ID); ?>
    <?php echo $page_image[0]; ?>

    But it does not work in custom page templates. Can not understand why...

    Any solutions?

  6. MichaelH
    Volunteer
    Posted 2 years ago #

    Works fine for me using the WordPress Default theme with custom page template and the page.php that comes with WordPress. This right after get_header;

    <?php echo 'post id ' . $posts[0]->ID; ?>
  7. Aen
    Member
    Posted 2 years ago #

    Works for me thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic