Display post by id from custom field

Community Forums Forums General Discussion Display post by id from custom field

This topic is: not resolved

This topic contains 1 reply, has 1 voice, and was last updated by  HelenaB 1 year, 6 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #34012

    HelenaB
    Participant
    Post count: 47

    Hi all.

    I’m trying to display a certain post’s title, excerpt, featured image and link after a given page’s content.

    This works perfectly in the editor itself and in Simple Hooks after_post_content:

    [html][display-posts include_excerpt="true" id="221"  image_size="thumbnail" wrapper="div"][/html]

    But I need it to be simpler for the user, so I’d like them to just be able to enter the id of the post they want to appear in a custom field called casestudy – but I’m having trouble getting it to work.

    I’ve tried adding the following via simple hooks in genesis_after_content but if I tick execute PHP and shortcode it lists all posts rather than just one.  If I tick execute PHP it echoes the shortcode exactly as written above so it should be correct?

    [php]<?php if( genesis_get_custom_field( ‘casestudy’ ) ) { ?>
    [display-posts include_excerpt="true" id="<?php genesis_custom_field("casestudy" ); ?>" image_size="thumbnail" wrapper="div"]
    <?php } ?>[/php]

    What am I doing wrong?

    Thanks in advance

    #34311

    HelenaB
    Participant
    Post count: 47

    Any suggestions most welcome!

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.