Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • Stefan Girndt

    I have created a shortcode “maps” with the following content that uses the shortcodes “city” and “state” to display the correct map for that location:

    <div align=”center”>
    <div class=”gmap_canvas”><iframe id=”gmap_canvas” src=” name='city'],[sc name='state']&t=&z=13&ie=UTF8&iwloc=&output=embed” width=”100%” height=”400″ frameborder=”0″ marginwidth=”0″ marginheight=”0″ scrolling=”no”> </iframe></div>

    But the actual content of the shortcodes “city” and “state” aren’t used and only the code as displayed above can be found in the source code of the page.
    Is there anything to consider when using shortcodes inside html-parameters that uses “” (besides using ‘ for the shortcode name)?

    Hi Stefan,

    Thanks for using Shortcoder.

    I would suggest trying the below format which is very simple. Looks like you are complicating.

    It makes use of “custom parameter” feature.

    Custom parameters

    Inserting shortcode inside attributes is tricky. WordPress is confused and fails to parse.

    Create a single shortcode named maps
    Put this a content

    <div align="center">
    <div class="gmap_canvas"><iframe id="gmap_canvas" src=",%%state:texas%%&t=&z=13&ie=UTF8&iwloc=&output=embed" width="100%" height="400" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"> </iframe></div>

    Here city and state are the custom parameters with default values Austin and texas. These can be changed when using the shortcode.

    Now use the shortcode [sc name="maps" city="denver" state="colorado"]

    That’s it!


    Stefan Girndt

    I still don’t get it to work using my already existing shortcodes for city and state.
    In your example, I would still have to edit the values for city and state on the page where I use the maps shortcode.

    I wanted to edit the value for city only in the city shortcode and that value would be used everywhere else.

    I tried with

    [sc name=”maps” city=”[sc name='city']” state=”[sc name='state']“]

    But that still didn’t work…

    Instead of creating separate shortcodes for city and state. Any reason for this? it is better to use parameters like I mentioned. It works exactly like you want.

    It does not make sense to create shortcodes for simple words.

    WordPress is failing to parse like mentioned earlier. This is for any shortcode not only shortcoder.

    Stefan Girndt

    I want to create a website template that I can easily fill with the business details of a prospect.
    All business information (Name, phone, email, address etc.) goes into shortcodes and can be used wherever I want to reference this information.

    Especially the city and state will be used all throughout the website on different pages.
    And I want to update to a new business in one spot without going through all the pages and updating the information manually.

    Perhaps shortcoder isn’t the right tool for this use case?

    The way I suggested is the best way to get it done.

    Since shortcodes are set as attribute values parsing is not working as expected. This is not only shortcoder but for any shortcode. They will be printed as is.

    Another approach I can think is, create city and state shortcode like you have now.
    And for the maps shortcode follow the method I told.

    Now when you want to edit the city and state names, you must edit two shortcodes (maps & city/state). This will be the trade-off.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Subscribe for updates

Get updates on the WordPress plugins, tips and tricks to enhance your WordPress experience. No spam. View newsletter