Home » Wordpress

Left or Right Align your image, adsense code or other advertisement in wordpress

21 November 2008 338 views One Comment Popularity: 4% Share/Bookmark

Suppose you want to show your google adsense in the top-left side of your post. If you simply put your adsense code in the single post page (single.php) of wordpress then the text of your post will appear below the adsense.

To solve this problem, I used stylesheet property called ‘margin’. The example below is from single.php file of my wordpress theme. The adsense code is kept in between the

tag. It is kept after

and before function.

<div class="entry-content">

<p class="alignleft" style="text-align: left; margin: 8px; float: left;">

<script type="text/javascript"><!--
google_ad_client = "pub-8802303964745491";
/* 336x280, created 5/16/08 */
google_ad_slot = "7152897181";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

</p>

<?php the_content(''.__('Read More <span class="meta-nav">&raquo;</span>', 'sandbox').''); ?>

Similarly, I created an about me page. I wanted to show my pic in the top-left position and to show the text by the side of the pic. For this I added style to my uploaded image while editing the page. I went to the HTML (not View) section in the edit/add page.

The style I added goes like this:

style="margin: 8px; float: left;"

More HTML source from my about page:


<p style="text-align: left;">
<img class="alignleft" alt="Mukesh Image" src="http://blog.chapagain.com.np/wp-content/uploads/close-up-small.jpg" style="margin: 8px; float: left;"/>
</p>
<p> </p>
<p class="MsoNormal" style="text-align: justify;">
Hi, I am Mukesh Chapagain. My rest of the introduction goes here...
</p>

Related posts:

  1. Wordpress Plugin: Quick Adsense 1.0
  2. How to setup Google AdSense for your website
  3. How to show child page (sub page) list in parent page in wordpress?
  4. New Wordpress Plugin – Author Introduction
  5. Solution: Google Adsense not showing on my website blog

One Comment »

  • Chris Felts said:

    the align code worked perfect for my adsense thanks

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.