- This topic has 17 replies, 3 voices, and was last updated 7 years, 5 months ago by Pratik.
-
AuthorPosts
-
July 15, 2016 at 4:57 pm #95526spespamParticipant
Hello,
I would like to insert an adsense banner just under the menu but I can’t manage to do it.
Can somebody help me to do it ?
Thank you !
July 16, 2016 at 5:38 pm #95545PratikParticipantCan you post in your site url?
July 16, 2016 at 6:57 pm #95551spespamParticipantHello Pratik
Why do you need my url ? Isn’t catchbox the same for everyone who uses it ?
July 17, 2016 at 10:07 am #95571PratikParticipant@spespam:
Although the theme is same, different sites have different conditions due to plugins used. It will be better if you could provide me with the site so I cna check it the adsense code would work on the place where you want.June 24, 2017 at 3:49 am #118066wordazParticipantHello,
I also have this challenge. Im trying to add adsense link units below the menu and below the fold. My website is https://mtn4u.com/
Kindly assistJune 24, 2017 at 10:36 pm #118089PratikParticipantHi @wordaz,
You have two menus and then slider. Where exactly do you want the ad?
First thing first, for this, you will need to create a child theme. First, create a child theme using tutorial: http://catchthemes.com/blog/create-child-theme-wordpress/
Then, let me know where you want the add and I will provide you code to place the ad.
Regards,
PratikJune 26, 2017 at 9:36 am #118128wordazParticipantHello, Thanks for the info.
I have set up a child theme on the website. I want to place the ad inbetween the 2nd menu and slider.
Also how do I add ads to my home page,
1) just below the featured content section
2) Just above featured content section/below slider section
2) inbetween each post brief as seen on home page (maybe doing so every couple of posts). Please is this possible?I want to try out these various options to see which one will best suit the site
Thank you and regards
June 27, 2017 at 12:44 am #118170PratikParticipantHi @wordaz,
First make function and add it to functions.php file:
function clean_journal_child_ad(){ ?> <!-- Add google ad code here --> <?php }
Then after this function, add following code in functions.php as given condition:
Inbetween the 2nd menu and slider:add_action( 'clean_journal_before_content', 'clean_journal_child_ad', 5 );
1) just below the featured content section
add_action( 'clean_journal_before_content', 'clean_journal_child_ad', 45 );
2) Just above featured content section/below slider section
add_action( 'clean_journal_before_content', 'clean_journal_child_ad', 30 );
2) inbetween each post brief as seen on home page (maybe doing so every couple of posts). Please is this possible?
* For this, you will need to hire a customizer. This now has gone beyond our theme support scope.regards,
PratikJune 27, 2017 at 3:34 am #118187wordazParticipantHello Pratik.
Im not sure Im getting this right as its not working. I went to Themes – Child Themes – Files – “Click to edit Files using Child Theme Editor”The last line of code in the “Clean Journal Child 02: Theme Functions (functions.php)” is;
endif;
add_action( ‘wp_enqueue_scripts’, ‘child_theme_configurator_css’ );I then added the following immediately after it;
function clean_journal_child_ad(){
?>
<!– Add google ad code here –>
<?php
}
add_action( ‘clean_journal_before_content’, ‘clean_journal_child_ad’, 45 );and then saved. Nothing however is reflecting on my webpage.
Pls assist. What did I do wrong.? How do I rectify it?
June 27, 2017 at 3:37 am #118188PratikParticipantHi @wordaz,
You need to replace
<!– Add google ad code here –>
with your google adsense code.June 28, 2017 at 7:09 am #118255wordazParticipantHi Pratik,
Ive tried all that but nothing seems to be working at the moment. (I even tried adding “if” and “endif” statements to no avail). It fails to render in the preview.
Currently my child themes “functions.php” code looks like this;
<?php
// Exit if accessed directly
if ( !defined( ‘ABSPATH’ ) ) exit;// BEGIN ENQUEUE PARENT ACTION
// AUTO GENERATED – Do not modify or remove comment markers above or below:if ( !function_exists( ‘chld_thm_cfg_parent_css’ ) ):
function chld_thm_cfg_parent_css() {
wp_enqueue_style( ‘chld_thm_cfg_parent’, trailingslashit( get_template_directory_uri() ) . ‘style.css’, array( ) );
}
endif;
add_action( ‘wp_enqueue_scripts’, ‘chld_thm_cfg_parent_css’, 10 );
function clean_journal_child_ad(){
?>
<!– <script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
<!– MTN4U Banner Ad –>
<ins class=”adsbygoogle”
style=”display:inline-block;width:728px;height:90px”
data-ad-client=”ca-pub-****************”
data-ad-slot=”**********”></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script> –>
<?php
}
add_action( ‘clean_journal_before_content’, ‘clean_journal_child_ad’, 30 );// END ENQUEUE PARENT ACTION
Kindly advise on what Im doing wrong.
Thanks
June 28, 2017 at 7:27 am #118257PratikParticipantHi @wordaz,
Are you sure there is line
<!– <script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
, the initial<!--
comments out the code. Please check the code again properly.Your function should look like following:
function clean_journal_child_ad(){ ?> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-1234567890123456" data-ad-slot="1234567890"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> <?php }
You need to remove the comments
<!--
and-->
at start and end, don’t just remove the text.June 28, 2017 at 9:36 am #118268wordazParticipantThanks a lot Pratik.
Working perfectly now.
Cheers
June 29, 2017 at 12:00 am #118282PratikParticipantHi @wordaz,
I quickly checked your site and saw it working. There is some cdsign issue with google ad. You can fix it using following code in Appearance=> Customize=> Additional CSS box:
ins.adsbygoogle { background-color: #ffffff; text-align: center; }
This should blend the google code.
Finally, if you liked my supportm, it would be great if you could leave a review at https://wordpress.org/themes/clean-journal/. A positive review would be great 🙂
Regards,
PratikJune 29, 2017 at 2:40 am #118288wordazParticipantOh, thanks a lot – Just finished that review.
Meanwhile, I used the same code for my other site but its not having the same effect (not blending in the Google code)
I also noted that after adding my google adsense code for the site following your instructions for my 1st site (mtn4u.com), the top article (title and “more”) in the scroll down list does not highlight and is no longer clickable. It is also difficult to click the articles in the “Recent Posts”.
Can you help me look at it pls. The site is
https://intechreviews.com/June 29, 2017 at 2:53 am #118290PratikParticipantHi @wordaz,
I checked your site and you have made mistake in copying and pasting the code. The code you have pasted is
ns.adsbygoogle { background-color: #ffffff; text-align: center; }
,
please make sure you have i.
full code:
ins.adsbygoogle { background-color: #ffffff; text-align: center; }
June 29, 2017 at 2:56 am #118291wordazParticipantThank you.
Working perfectly now
CheersJune 29, 2017 at 3:00 am #118292 -
AuthorPosts
- The topic ‘insert adsense under the menu’ is closed to new replies.