Title: Ads per Author With PHP Function
Last modified: February 8, 2017

---

# Ads per Author With PHP Function

 *  Resolved [ANGE1K](https://wordpress.org/support/users/erzr/)
 * (@erzr)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/ads-per-author-with-php-function/)
 * Hello Igor,
 * First of all, let me tell you that you have developed an amazing plugin. However,
   I got some issues around the following code:
 *     ```
       		<?php $author = get_post_field('post_author', get_the_ID());
       		if ($author == '3') { 
       		echo adinserter(1); 
       		} elseif ($author == '3') { 
       		echo adinserter(2); 
       		} elseif ($author == '3') {
       		echo adinserter(3);
       		} else {}
       		?>
       ```
   
 * However, It seems like the code is not working for me… I tried to put this file
   in the functions.php and also single.php and the adds are still showing up doesn’t
   matter who author wrote the article.
 * It seems that I cannot find a way to actually place the php function. I am begging
   you, please, if there’s a way around this let me know as fast as you can.
 * Thanks in advance!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [ANGE1K](https://wordpress.org/support/users/erzr/)
 * (@erzr)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/ads-per-author-with-php-function/#post-8770111)
 * Igor, I finally managed to do it. If you allow me I can post the code on this
   forum.
 * Best Regards,
    Angel.
 *  Thread Starter [ANGE1K](https://wordpress.org/support/users/erzr/)
 * (@erzr)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/ads-per-author-with-php-function/#post-8770177)
 * Oh, another fact is that when I select only on selected pages and use the shortcode
   like this
 * if ($author_id==”1″) {
    echo do_shortcode(‘[adinserter block=”1″]’); echo do_shortcode(‘[
   adinserter name=”Block 2″]’);
 * The settings on the add do not apply, which means they are one after another 
   and doesn’t go after any paragrah…
 *  Plugin Author [Spacetime](https://wordpress.org/support/users/spacetime/)
 * (@spacetime)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/ads-per-author-with-php-function/#post-8776658)
 * I’m not sure if I understand your problem.
 * If you use Ad Inserter shortcode then the code for the block will appear exactly
   where the shortcode is present – or echoed. This has nothing to do with paragraphs.
   Paragraph (and many other) block settings apply to automatic insertion, but you
   are using manual insertion – shortcodes.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Ads per Author With PHP Function’ is closed to new replies.

 * ![](https://ps.w.org/ad-inserter/assets/icon-256x256.jpg?rev=1502039)
 * [Ad Inserter - Ad Manager & AdSense Ads](https://wordpress.org/plugins/ad-inserter/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ad-inserter/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ad-inserter/)
 * [Active Topics](https://wordpress.org/support/plugin/ad-inserter/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ad-inserter/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ad-inserter/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Spacetime](https://wordpress.org/support/users/spacetime/)
 * Last activity: [9 years, 3 months ago](https://wordpress.org/support/topic/ads-per-author-with-php-function/#post-8776658)
 * Status: resolved