• 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

Custom Post ID and Plugin Shortcode

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 › Custom Post ID and Plugin Shortcode

This topic is: not resolved

Tagged: post id, shortcode

  • This topic has 4 replies, 2 voices, and was last updated 7 years, 2 months ago by CYBERsprout.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • December 22, 2015 at 9:13 pm #174597
    CYBERsprout
    Member

    I'm trying to print a custom post id for some shortcode that needs the id. There is some error that I'm missing.

    The code is placed in the genesis_entry_content hook. Any suggestions are much appreciated!

    <?php
    if (is_singular('wpseo_locations')) {

    [wpseo_address id="<?php the_ID(); ?>" hide_name="1" show_state="1" show_country="0" show_phone="1" show_phone_2="0" show_fax="0" show_email="0" show_url="1"]

    [wpseo_map id="<?php the_ID(); ?>" width="1000" height="500" zoom="-1" map_style="roadmap" scrollable="1" draggable="1" show_route="0" show_state="0"]

    <?php }
    ?>

    December 22, 2015 at 10:33 pm #174607
    Brad Dalton
    Participant

    Please embed your code correctly so it can be tested.

    Also, use the 2nd and 3rd code snippets on this page as a guide to learning how to print a shortcode.

    You'll need to change the hook, conditional tag and shortcode in the code example.


    Tutorials for StudioPress Themes.

    December 23, 2015 at 10:34 am #174646
    CYBERsprout
    Member

    Brad, thanks for the reply. I should mention that I'm using the Genesis Simple Hooks plugin. The code is outputting in the right place but essentially breaks when it is supposed to start pulling data based on the custom post id. Should I still be using do_shortcode()?

    <?php
    if (is_singular('wpseo_locations')) {
    echo "<b>Contact Details</b><br>";?>
    
    [wpseo_address id="<?php the_ID(); ?>" hide_name="1" show_state="1" show_country="0" show_phone="1" show_phone_2="0" show_fax="0" show_email="0" show_url="1"]
    
    [wpseo_map id="<?php the_ID(); ?>" width="1000" height="500" zoom="-1" map_style="roadmap" scrollable="1" draggable="1" show_route="0" show_state="0"]
    
    <?php    }
    ?>

    Here is what it outputs:

    Contact Details
    URL: 
    December 27, 2015 at 12:15 pm #174606
    Brad Dalton
    Participant

    Please embed your code correctly so it can be tested.

    Also, use the 2nd and 3rd code snippets on this page as a guide to learning how to print a shortcode.

    You'll need to change the hook location, conditional tag and shortcode in the code example.


    Tutorials for StudioPress Themes.

    January 2, 2016 at 10:13 am #175391
    CYBERsprout
    Member

    I can't get it to work with '

    ' tag so I haven't used it. It keeps outputting like this:
    
    [php]&lt;?php
    if (is_singular('wpseo_locations')) {
    echo &quot;&lt;b&gt;Contact Details&lt;/b&gt;&lt;br&gt;&quot;;?&gt;
    
    [wpseo_address id=&quot;&lt;?php the_ID(); ?&gt;&quot; hide_name=&quot;1&quot; show_state=&quot;1&quot; show_country=&quot;0&quot; show_phone=&quot;1&quot; show_phone_2=&quot;0&quot; show_fax=&quot;0&quot; show_email=&quot;0&quot; show_url=&quot;1&quot;]
    
    [wpseo_map id=&quot;&lt;?php the_ID(); ?&gt;&quot; width=&quot;1000&quot; height=&quot;500&quot; zoom=&quot;-1&quot; map_style=&quot;roadmap&quot; scrollable=&quot;1&quot; draggable=&quot;1&quot; show_route=&quot;0&quot; show_state=&quot;0&quot;]
    
    &lt;?php    }
    ?&gt;
  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 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

© 2023 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