WordPress.org

Support

Support » Plugins and Hacks » Create shortcode which contains PHP

Create shortcode which contains PHP

  • I need to provide client with a short code which echo a stored session variable. Essentially what I want to do is this:

    Client has some text in the wordpress editor on a page or post

    Blah blah blah blah Join Now!

    Client wants to link Join Now to <a href="http://www.mydomain.com/join.php?id=SOME_USERNAME">Join Now!</a>

    If I was doing this in PHP I would do:
    <a href="http://www.mydomain.com/join.php<?php echo '?id=' . $_SESSION['SponsorID']; ?>">Join Now!</a>

    What I want to do is create a shortcode such as [sponsor_id] and allow the client to create a link like this:
    <a href="http://www.mydomain.com/join.php[sponsor_id]">Join Now!</a>

    The client is very hip to using shortcodes and could easily remember this, but not so much on remember all of the PHP.

  • The topic ‘Create shortcode which contains PHP’ is closed to new replies.
Skip to toolbar