- This topic has 6 replies, 2 voices, and was last updated 3 years, 6 months ago by Tom.
November 9, 2017 at 2:56 am #419314themedleb
If we are two or more authors in the website, each with it’s own adsense code, we need our ads to be displayed on single posts, each specific ad should be displayed in the single post where a specific author posted/published it.
user-id: 1111 | adsense code: aaaa
user-id: 2222 | adsense code: bbbb
user-id: 3333 | adsense code: cccc
user-id: 4444 | adsense code: dddd
if random post published by user-id: 1111, the adsense code: aaaa should appear
if random post published by user-id: 2222, the adsense code: bbbb should appear
if random post published by user-id: 3333, the adsense code: cccc should appear
if random post published by user-id: 4444, the adsense code: dddd should appear
and so on …
Is there a PHP code I can insert in single.php/content-single.php to show a specific thing (let’s say shortcode) to appear when a specific author wrote the post?
Thank you.GeneratePress 1.4GP Premium 1.5November 9, 2017 at 9:53 pm #420307TomLead DeveloperLead Developer
Hmm, something like that would take quite a bit of coding I think – a bit too much for the forum here.
Your best bet would likely be a plugin – there must be one out there, as I would think it’s a pretty common problem.November 10, 2017 at 6:01 am #420674themedleb
Oh, I asked because I thought it’s going to be just like a code you used to give before, something like:
Of course this has no sense since I have no clue on PHP, I’m just trying to guess from random thoughts lol. Anyway, thank you.November 10, 2017 at 9:47 am #420950themedleb
Unfortunately I looked in WordPress repo inside WordPress and from Google, there is no plugin offers this.
I found the function is_author https://developer.wordpress.org/reference/functions/is_author/ but I don’t know how to use it, and don’t know if I can add it with is_single function to work as: if it’s a single post + written by author(‘4’) then show this shortcode.November 10, 2017 at 7:57 pm #421297TomLead DeveloperLead DeveloperNovember 11, 2017 at 7:33 am #421700themedleb
Wow It works, I was so worried about this, thank you Tom for your kind help and precious time.November 11, 2017 at 8:31 am #421757
- You must be logged in to reply to this topic.