WordPress.org

Forums

Create shortcode which contains PHP (1 post)

  1. aeboi80
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic