• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Display post by id from custom field

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

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

This topic is: not resolved

Tagged: Custom fields, shortcode, Simple Hooks

  • This topic has 1 reply, 1 voice, and was last updated 12 years, 8 months ago by HelenaB.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • April 8, 2013 at 10:38 am #34012
    HelenaB
    Participant

    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:

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

    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 if( genesis_get_custom_field( 'casestudy' ) ) { ?>
    [display-posts include_excerpt="true" id="<?php genesis_custom_field("casestudy" ); ?>" image_size="thumbnail" wrapper="div"]
    <?php } ?>

    What am I doing wrong?

    Thanks in advance

    April 9, 2013 at 12:24 pm #34311
    HelenaB
    Participant

    Any suggestions most welcome!

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble