WordPress.org

Forums

Multiple Parameters for a Shortcode (4 posts)

  1. Abhik
    Member
    Posted 2 years ago #

    Hello,
    I am working on building some shortcodes for my blog.
    I can set a single parameter for my shortcode, but not sure how to set different parameter.

    For example, I can use [myshortcode myvalue] to output a html block within the post content.

    Now, how can I use [myshortcode myothervalue] to output a different block of html?

    Please note that the shortcode is same, only the parameter is changed.

  2. alchymyth
    Forum Moderator
    Posted 2 years ago #

    review:

    http://codex.wordpress.org/Shortcode_API

    try to use attributes, so you can use, for example:

    [myshortcode value="my"]
    and
    [myshortcode value="myother"]

  3. Abhik
    Member
    Posted 2 years ago #

    alchymyth,
    Thanks for replying. I know I can do that, but that's not exactly what I want.

    Is there anything that serves my requirements?

  4. alchymyth
    Forum Moderator
    Posted 2 years ago #

    the shortcode is same, only the parameter is changed.

    that is usually doen with the attributes.

    Is there anything that serves my requirements?

    possibly start by posting the code of your existing shortcode - this might help to explain what you want.

    what stops you to use two different shortcodes?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags