So this is telling my website to display the “bgphotos” div when a link is clicked on from “http://www.testdomain.com/testpage” and then display the “bgvideos” div when a link is clicked on from anywhere else. This works great!!

Now the current problem I’m having is that on my main website I’m going to have a section called news, a section called videos and a section called photos. I’d like to track where these clicks are from just like I did above. But these sections are not pages, they are divs. So that is where it gets tricky.

Again, I would like to track where clicks are from in a specific div / section and not just a page. If anyone knows if this is possible or knows a solution of any sort, please let me know. 🙂 It would honestly mean soooo sooo, sooo, soo much to me, it honestly would!

JavaScript is your friend… You could simply use JavaScript to update the URL query string on click. Then you could use $_SERVER['QUERY_STRING'] and add that to your already existing if/else statement. Let me know if you need some help with that.

jQuery will make short work of it since WordPress already has jQuery up and running.

@wpismypuppet Hey man, I never even thought of using JS! It sounds quite simple how you explained it, but I honestly have no idea where to start. loll. I’m kind of a noob when it comes to JS, and even PHP. But yeah, I would like to track where clicks are from in a specific div / section and not just a page, so how exactly would I do that using Java or the query string? You said I could use JS to update the URL query string on click. I don’t really know how to go about doing that. 🙁 So so if I had a news section with blogposts under my home page would I have to specify the Query_string for the news section and then add that into my php if/else statement? I don’t know how to do that or if that even made sense. But yeah it would be awesome if you could explain how to do it a bit more and as of right now I’m googling query strings and how they work 🙂 Thanks for the help and if you want I could give you my e-mail to communicate faster!

You know what? The more I thought about it, the less JavaScript and $_SERVER[‘QUERY_STRING’] you need. In other words, you need zero of both. It’s late, forgive me.

Here’s what you do… on the main page that has your sections, append the query string to the hyperlink itself. For example, your news section has a hyperlink to http://www.testdomain.com/testpage, right? Simply add ?fromwhere=news to the end. So something like:

This isn’t tested, but should work just fine. It will at least point you in the right direction. Also, please note that when you write PHP code, you should ALWAYS open code blocks with <?php and not just <?. <? can also declare XML and some other languages, so it’s best to forget the short code ever existed! 🙂

@wpismypuppet awesome man! thank you so much! But the main problem is that the news posts, video posts and photos posts aren’t just hyperlinks that I manually made, they are generated titles and thumbnails spit out through a plugin I’m using. But there is nothing I can do about that, I’ll just have to dig through the coding and find a way to append the query string to the hyperlinks that the plugin generates. 🙂

Thanks for all the help, if you don’t mind could I tell you my e-mail and I could get back to you once I test this out fully?

Well, I’d have to see the code to help you better. Do you have a link to your website? I could check out the source and see more what you’re talking about. We may have to rethink the JavaScript approach.

The problem with changing the code in the plugin is that you’ll lose those changes if and when you update the plugin! So that might not be the best option…

And forgive me, but I don’t give my email out here on the forum as I don’t like to have random people email me with questions 🙂 Simply respond to this thread and I’ll get the message!

There are four thumbnails at the top. Some goto external URL’s. I got this to work with a few little tricks :). Anyways, The second thumbnail goes to an actual post, along with all the other smaller thumbnails below out. But like I said the single posts are broken at the moment. Here is what I did.

And I was going to put the “?fromwhere=news” code at the end of the php code that grabs the url for the thumbnails that link to posts but I didn’t bother because the single posts aren’t even working yet 🙁

Thanks so much for the help man. It works pretty much. I just need to test it with a few more things / plugins. I’m kinda worried that I’ll lose contact with you. Are you sure I can’t give you my e-mail? You don’t have to post yours… If not its all good, I’ll be posting with an update tommorow. 🙂