WordPress.org

Forums

Displaying Featured Image When Including Page (4 posts)

  1. mattblank
    Member
    Posted 2 years ago #

    Hi,

    I'm using the below code to include a pages content into a template.

    <?php
    $post_id = 12;
    $queried_post = get_post($post_id);
    ?>
    <h2><?php echo $queried_post->post_title; ?></h2>
    <?php echo $queried_post->post_content; ?>

    I'd also like to use: <?php the_post_thumbnail('');?>

    How can I make that appear so that within that section it shows the featured image of that post, and not the page it's being display on?

    Thanks!
    Matt

  2. Michael
    Forum Moderator
    Posted 2 years ago #

  3. mattblank
    Member
    Posted 2 years ago #

    Thank you! So same question then for including certain custom fields i.e.

    <?php $field_name="musicinfo"; $field_value = get_post_meta($post->ID, $field_name, true);?>

    Many thanks for your help!!
    Matt

  4. mattblank
    Member
    Posted 2 years ago #

    Ah ignore me :)

    I realised it would just be:

    <?php $field_name="musicinfo"; $field_value = get_post_meta($queried_post->ID, $field_name, true);?>

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.