Render shortcode outside loop

Ive abandoned my earlier attempt to generate the map dynamically with a custom address field and have decided to just insert a map per post manually. I have created a meta field called property map where i insert the map short code and attempting to call it from the post with <?php echo do_shortcode('[ecpt_field id="propertymap"]'); ?>

but it only renders the shortcode and not the map. if i place the shortcode in the content editor it works but outslide the content editor it doesnt render! how can i render the map using a metafield and not the content editor box?

  • Timothy Bowers
    • Chief Pigeon

    Hey there.

    How are you pulling the the meta outside of the loop?

    // Use shortcode in a PHP file (outside the post editor).
    echo do_shortcode('[map id="1"] ');

    Would be to use the Map ID 1.

    How are you passing in the data in and for the map?

    When you say it doesn't render, how do you mean, it shows nothing? It just shows the shortcode? something else?

    Might help if we can see all the code your using there.


  • Peter76
    • New Recruit

    I add the map to the post using the globe icon beside the upload and click insert map..........the map shortcode gets inserted into the main editor. I cut that code and paste it into a Custom Meta Box that is part of a custom post type ive created.

    the meta box is named propertymap

    I added <?php echo do_shortcode('[ecpt_field id="propertymap"]':wink:; ?> to single.php
    in order to position it where i need it to show. but it just shows in the front end as [map id="35"] rather than the map (thats what i meant by the map doesnt render)

    If i add the short code in the editor the map shows up, if its in the metabox it just shows the raw short code in the front end.

    Sorry if its not clear. see if the screen shot helps!

  • Timothy Bowers
    • Chief Pigeon

    Still ntohing.if it filtered to remove the " wwouldnt it just show the map id=35? or would it jsut block everything? im trying on another theme to determine if its my theme that doesnt allow this.......

    I ask because it filtered mine on a custom field, screen attached.

    How did the other theme test go?

    Let me know.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.