Swedish flagChinese (Simplified) flagEnglish flagGerman flagFrench flagSpanish flagHindi flag
June
24
2009
3

Formatting Google AdSense

I have added google ads to techonomics.se to make the business profit. Yet it has not produced any results, but we'll see.
The question is how you manage to get an ad in the first three posts on your blog? The fact is that you as an AdSense user may only have three ads per html page. If you have several items on the front page of your blog it may be time to run ads on the top three.
The solution is to edit the index.php (or similar) where your posts are listed. Create a counter, $counter = 1; at the beginning of the file in a tag:. After you place your ad where the while loop adds the contents of your records and lists $counter = $counter +1 ; . Do a test to $counter <= 3 when posting annonsscriptet.

Here's what the code looks in more detail:

  <? Php
 get_header ();
 $ Counter = 1;
 ?> 
  ... 
  <? Php if (have_posts ()): while (have_posts ()): the_post ();?> 
  ... 
  <div class=""storycontent"">
 <? Php
 if ($ counter <= 3) {
 echo ('
 <Your AdSense annons>
 ');
 }
 $ Counter = 1 + $ counter; 
  ?> 
  ... 

Of course, a format to be done, e.g. with CSS, to fix a good placement of the ad. Then create a div with class ad has the right format and place it around the ad.
Something else that is good is to give each post an ad. In my theme is called a single post single.php. You do not have to worry about any counter, it is enough to put an ad!

January
25
2009
-

Edit Word Press theme

I have added an author tag in my posts (↑). To do that, I could use my picture and e-mail directly, but I chose to make it more dynamic. On this page:

http://phpxref.ftwr.co.uk/wordpress/nav.html?_functions/index.html

you will find all the features that are predefined in WordPress. By taking advantage of this feature get_avatar seen get avatar image:

  <? Php
    echo get_avatar ($ id_or_email, $ size = '96 ', $ default =' <path_to_url> ');
    ?> 

To always be the author of the current post that get into the picture, I use the function

get_the_author_id ()

on-site for $ id_or_email.

To print the author's name and email also features get_author () and get_author_email (). Function Library is a gold mine to save time when you build your own theme / modify someone else's!

(The formatting of my author tag is then built using css that is added in style.css)

The theme is modified from Aeros 2.0 - Blogglista.se - Translation is made ​​by N2H