Show Adsense Ads Below Post Title in WordPress Blog

I am going to tell you how to show your google adsense ads below the title of the post.We are going to modify the theme directly and create a widget area below the post title.The Ad is going to show below the post title and the content will follow after the ad has finished.

Step 1 – Creating the widget area

Open functions.php inside your theme folder and add this code anywhere but not inside any function

function additional_widgets_init() {

       register_sidebar( array(
		'name'          => 'Widget Below Post Title',
		'id'            => 'WidgetBelowPostTitle',
		'before_widget' => '',
		'after_widget'  => '',
		'before_title'  => '',
		'after_title'   => '',
	) );

add_action( 'widgets_init', 'additional_widgets_init' ); ?>

the Widget ‘Widget Below Post Title’ is now available in the widgets in your Admin.

Step -2 Adding the Widget to Your theme

Open single.php in your theme folder. Now you need to identify the title of the post in this file.Look for the function the_title(); Add the following code just after the div tag.

<?php if ( is_active_sidebar( 'WidgetBelowPostTitle' ) ) : ?>
	<div id="WidgetBelowPostTitle">
		<?php dynamic_sidebar( 'WidgetBelowPostTitle' ); ?>
<?php endif; ?>

Go to your widgets section in Admin and Add a text widget containing the Adsense Ad Code to your widget Area WidgetBelowPostTitle You can also use the id WidgetBelowPostTitle in your style.css for styling the contents of the widget area.

Hopefully if all is well you should see the Ads below the post title.

That is all.

If you liked this article please do leave a reply and share it with friends.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.