• [ Moved to the Fixing WordPress sub-forum. ]

    Very brain dead today. I want to change the format of a post based on where the visitor came from. I get visitors from ABC.COM and want them to see the post with different headers, pictures etc. I don’t need to change css code, it will be just html. Something like this.

    If referrer contains string”ABC.COM”
    html code for title, header image, etc
    else
    html code for alternate title, header image, etc.
    endif

Viewing 5 replies - 1 through 5 (of 5 total)
  • Something like this?

    if( strpos ($_SERVER['HTTP_REFERER', 'abc.com') === false ) {
        echo '<p>Standard HTML code.</p>';
    }
    else {
        echo '<p>ABC.com HTML code.</p>';
    }
    Thread Starter billjones

    (@billjones)

    I tried this and didn’t get the echo of either statement.
    This the url of the post. http://pdxrealestatephotography.com/virtual-tour-1495-ne-zachary-st-hillsboro/

    <?php
    if( strpos ($_SERVER[‘HTTP_REFERER’, ‘rmls.com’) === false ) {
    echo ‘

    Standard HTML code.

    ‘;
    }
    else {
    echo ‘

    rmls.com HTML code.

    ‘;
    }
    ?>

    Where did you put the code? If it’s in the right place it has to output something no matter what, so the most likely problem is that you don’t have that bit of code in the right file, or place.

    Thread Starter billjones

    (@billjones)

    posted at the top of a wordpress post. view sample link and then view source.

    OK, I see what you’ve done.

    That’s wrong. You can’t use PHP code directly in a post/page/etc’s content area (unless you’re using a plugin to allow it, but I don’t personally recommend that for the majority of sites). That code should be placed either in a page template, or as a shortcode if it’s needed inside content or in multiple places.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘if statement based on referrer’ is closed to new replies.