Add Adsense ads
-
Hello!
How could add Adsense ads at the end of each post.
I would also put some in the head, next to the logo.
A greeting.
-
This post explains how to create a dynamic sidebar to contain the ad widget. If you want it to show up on the home page and cagtegory pages after every post you’d insert the sidebar code at the end of the content.php file. To show ads in the header you’d add the dynamic sidebar code to the header.php file, probably just before the header nav menu container.
In the theme options-sidebars, in the sidebars, add new, in the sidebar, content-ads
I added in the line 47, It would be right ?, well:
<?php if ( ot_get_option( 'post-nav' ) == 'content') { get_template_part('inc/post-nav'); } ?> <?php dynamic_sidebar('content-ads'); ?> <?php if ( ot_get_option( 'related-posts' ) != '1' ) { get_template_part('inc/related-posts'); } ?>All right, just do not know where I have to paste the adsense code
I haven’t used it but I think the adsense code goes in the test widget that’s added to the dynamic sidebar you create. Then, when you add the sidebar code to the php page, it generates the adsense script at runtime.
In the theme options-sidebars, in the sidebars, add new, in the sidebar, content-ads
I added in the line 47, It would be right ?, well:
<?php if ( ot_get_option( 'post-nav' ) == 'content') { get_template_part('inc/post-nav'); } ?> <?php dynamic_sidebar('content-ads'); ?> <?php if ( ot_get_option( 'related-posts' ) != '1' ) { get_template_part('inc/related-posts'); } ?>All right, just do not know where I have to paste the adsense code
Yes, as bdbrown says the adsense code has to be added in the test widget to the sidebar you’ve created. I’m using it.
Do not quite understand, not that bar, sorry for being such a newbie.
I would appreciate me explain in more detail
Basically the steps are:
1. Create a new sidebar in the Theme Options > Sidebars.
2. In Appearance > Widgets, add a text widget to the new sidebar.
3. Insert your adsense code into the text widget.
4. Add the php code to insert the sidebar into your site.
The example shown in the linked post was to place the ads after the end of a single post. If that’w where you want your ad then you would place the code in single.php as shown.I’ve already got, the problem now is that appears after the tags , and want to appear before .
Is this on your tuandropc site? Looks like you got it fixed.
Yes, but not if I did it correctly, I added the code in single.php file in the line 34:
I’m not sure q you have done well.
If correct, as I can leave more space between the ads and tags.
You could add a bottom margin like this:
#text-9.widget { margin-bottom: 20px; }Is that correct?
Where do I enter the code?
You’d enter that in your custom css or your child theme style.css file.
right
Thank again
The topic ‘Add Adsense ads’ is closed to new replies.
