WordPress.org

Ready to get started?Download WordPress

Forums

how to extract an attribute from a shortcode to use in a function? (1 post)

  1. StrangeAttractor
    Member
    Posted 2 years ago #

    I'm trying to write a function that looks into the content of a particular post for a Nextgen gallery shortcode, and then takes the number of the gallery in order to pull up a specific picture from the gallery.

    So, for example, the shortcode in the post might be
    [nggallery id=9]

    What I want is to write a function that gets the value of the id in the shortcode (9, in the example), and assigns it to a variable, e.g. $gallerycodeID.

    Is there a simple way to extract attributes like this from shortcodes in order to use them in other functions? Or do I need a regex string of some sort?

Topic Closed

This topic has been closed to new replies.

About this Topic