Insert Adsense iside ads
-
Hi,
Is there any way yo insert Adsense ads or other ads on tp and bottom of sd posts? Thank You
The page I need help with: [log in to see the link]
-
Hi,
do you mean the top and bottom of the single Ad page (for example https://demo.wpadverts.com/lite/advert/rayman-legends/)?If so then you can put the ads between the gallery and the title by adding this code in your theme functions.php file
add_action( "adverts_tpl_single_top", function( $post_id ) { echo "[ADSENSE TOP]"; }, 1 );You can add the ads after the contact options by adding the code below in the functions.php file
add_action( "adverts_tpl_single_bottom", function( $post_id ) { echo "[ADSENSE BOTTOM]"; }, 90000 );Of course, replace the [ADSENSE BOTTOM] and [ADSENSE TOP] with actual code for the AdSense ads.
Hi Greg,
Thanks for this but where should I insert the code inside the functions.php. I mean which part? I am getting an error. I’m sorry, I’m not that technical person. I am using divi theme and I am getting an error whenever I post the code inside the file. I want to insert the ad into this specific location is possible. https://www.screencast.com/t/0vaGxXly
Thank you,
RadenHi,
1. the code you can add at the end of the functions.php file but before?>if it’s at the end of file.The code itself should be fine (assuming your server is running PHP5.3 or newer) i tested it on my dev site before posting.
2. to insert the ads before description use the code below
add_action( "adverts_tpl_single_details", function( $post_id ) { echo "[ADSENSE MIDDLE]"; }, 90000 );Hi Greg,
I seem can’t find the
?>
Here’s the last part of the functions.php code
}
break;
case ‘_1_4__3_4’:
case ‘_3_4__1_4’:
case ‘_1_3__2_3’:
case ‘_2_3__1_3’:
case ‘_3_5__2_5’:
case ‘_2_5__3_5’:
$et_active_sidebar = array( 2, 3 );
break;
case ‘_1_4__1_2’:
case ‘_1_2__1_4’:
case ‘_1_5__3_5’:
case ‘_3_5__1_5’:
case ‘_1_4_1_2_1_4’:
case ‘_1_5_3_5_1_5’:
$et_active_sidebar = array( 2, 3, 4 );
break;
case ‘_1_2__1_6’:
case ‘_1_6__1_2’:
$et_active_sidebar = array( 2, 3, 4, 5 );
break;
}
}return $et_active_sidebar;
}
endif;Thanks a lot,
RadenHi Greg, by the way, are you talking about theme functions? Each theme has different files so I don’t know if what theme you have tested with. Happy to hear. I really want this to be working perfectly before we decide to purchase addons. We have 3 more classified ads and if this works we will use this plugin to all of our classified ads websites with all the needed addons.Thanks
Every theme has a functions.php file and adding the code i pasted in this file should insert the Ads regardless of the theme you are using.
In your case you should add the code i pasted after
endif;If adding the code will generate an error please paste the error message here, also let me know what is your PHP version.
Your PHP code changes were rolled back due to an error on line 9812 of file wp-content/themes/Divi/functions.php. Please fix and try saving again. syntax error, unexpected 'class' (T_CLASS), expecting ',' or ';'php version is 5.6
Your AdSense code causes a PHP fatal error.
Instead of double-quotes
echo " ... ";use single-quotesecho ' ... ';.Perfect! Thank you very much. I will ask if I have an additional question!
RegardsHi Greg, is there any way to create a space here? Google Adsense will not like this. Thanks again. https://www.screencast.com/t/vrVVPRyZ
I am also planning to add more content like related ads under each advert page. Can you suggest what file I should edit? Thanks
1. to have more space between ad and button in your custom code before the
<script ....>add<div style="height:20px; overflow: hidden; clear: both"></div>2. related ads snippet you can find here https://github.com/simpliko/wpadverts-snippets/blob/master/related-ads/related-ads.php and the installation instructions you will find at the end of the page here https://github.com/simpliko/wpadverts-snippets/
The topic ‘Insert Adsense iside ads’ is closed to new replies.
