WP-Refer

WP-Refer is a quick plugin I put together to record and display referers to individual posts. These are stored in custom fields (wp-refer) for each post. Certain referers can be excluded; by default Google and your site’s URL are excluded. Others can be added by editing the source code of wp-refer.php.

To install:

  1. Download wp-refer.phps
  2. Rename it wp-refer.php
  3. Upload it to /wp-content/plugins
  4. Activate it in the WP admin panel

To use:

  • <?php add_referer(); ?> must appear within ‘the loop‘ to add referers. Referers will only be added when an individual entry is being viewed.
  • <?php the_referers(); ?> displays a list of referers. I put mine in my wp-comments.php file. It defaults to a list (<li>) of the last 5 referers. Possible arguments include (in this order, defaults indicated):
    • 5: the number of referers to display, 0 for all
    • "<li>": HTML/text to prepend to each referer
    • "</li>": HTML/text to append to each referer
    • "none yet": Text to display when there are no referers yet

To see it in action, scroll to the bottom of this page, under the comment form.

History:

  • Version .5: First public release. Reversed sort of referers so most recent is first.
  • Version .4: Made it possible to exclude domains.
  • Version < .4: Getting it to work, squishing all sorts of bugs, etc.

4 Responses to “WP-Refer”


  1. 1 Ryan

    When I activated WP-refer, I got warnings when I publish new post. The warning is “Warning: Cannot add header information – headers already sent by (output started at /wordpress/wp-content/plugins/wp-refer.php:76) in /wordpress/wp-admin/post.php on line 147″. Can you help me?

  2. 2 manele

    thx for the plugin! i was searching a lot for this solution!

  3. 3 manele noi

    10q for this plugin …

  1. 1 Jonathan Foucher

Leave a Reply