Title: $Referer = Category?
Last modified: August 20, 2016

---

# $Referer = Category?

 *  [ianbee](https://wordpress.org/support/users/ianbee/)
 * (@ianbee)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/referer-category/)
 * I’ve sucesfully tracked where clicks are from and then made wordpress show elements
   based off where that click is from. A code example is this:
 *     ```
       <?php
       $referer = $_SERVER['HTTP_REFERER'];
   
       if ( $referer == "http://www.testdomain.com/testpage" ) {
       	echo '<div id="bgphotos"></div>';
       } else {
           	echo '<div id="bgvideos"></div>';
       }
       ?>
       ```
   
 * So this is telling wordpress to display the bgphotos div if it is clicked from
   [http://www.testdomain.com/testpage](http://www.testdomain.com/testpage). This
   works awesome. I’ve even done even more coding to track where certain divs are
   clicked on within a webpage. But, I would like to show an element if it was clicked
   on from a category.
 * Now, I thought the solution would just be to change the $referer to the category
   webpage. But the problem is, when there are more than one pages of posts for 
   this category, you would have to manually track each category page number… which
   would take forever.. An example would be:
 *     ```
       if ( $referer == "http://www.testdomain.com/category/test/" ) {
       	//do this }
   
       if ( $referer == "http://www.testdomain.com/category/test/page/2/" ) {
       	//do this }
   
       if ( $referer == "http://www.testdomain.com/category/test/page/3/" ) {
       	//do this }
   
       if ( $referer == "http://www.testdomain.com/category/test/page/4/" ) {
       	//do this }
       ```
   
 * As you can see this would just get out of hand, I would have to track every single
   category page possible. So is there any way to say, just track if something is
   clicked from a category?? Or any other solution to this problem?
 * Any help would be appreciated soo soo soo soo much! 🙂 loll

The topic ‘$Referer = Category?’ is closed to new replies.

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [problem](https://wordpress.org/support/topic-tag/problem/)
 * [referer](https://wordpress.org/support/topic-tag/referer/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [ianbee](https://wordpress.org/support/users/ianbee/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/referer-category/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
