That's basically what I need to accomplish. This is for wordpress. I don't want to use a plugin because there is none which does exactly what I want. I have a precise template that I made and want to keep as is, and plugins only let me insert ads on the sidebar and inside posts. So basically I need to write some PHP that will show an adsense code for a specific author, and another adsense code for everyone else. So something like: If author = tom, adsense2 else adsense1 You get what I'm trying to do? Please help, I know this should be simple to do, it's just going to be outputting a different ECHO depending on the author var, right? Thanks
You can get the author with this function http://codex.wordpress.org/Function_Reference/get_the_author Code (markup): Get the author check it's name then show the code you want.
Then set the variable in the loop and use it outside the loop. I guess you're checking for single post's author only.
Unfortunately I don't know enough about PHP to do this on my own. Can you please start me off with some basic code? I can understand and edit it, I just don't have the knowledge to write it from scratch
Check this: http://php.net/manual/en/language.variables.scope.php $my_username = '' //in loop global $my_username; $my_username = get_the_author(); //ad segment if($my_username == 'whatever'){ echo 'custom ad'; } else { echo 'common ad' } PHP: