Kjapp og trygg hosting for Wordpress

Annonse o.l. mellom poster

Msites Ltd

Livsnyter
Er det noen som har en enkel løsning (plugin eller kode) på hvordan man kan putte annonser e.l. mellom poster ?

Da tenker jeg f.eks mellom post 4 og 5 samt 8 og 9 på forsiden, arkiv, samt alle andre sider som viser flere artikler på en gang.

I mitt tilfelle skal jeg legge inn annonser med openx.

Jeg antar det kanskje må settes opp flere loops og ekskludere tidligere viste artikler slik at den fortsetter der den skal.....

Setter pris på alle gode forslag!
 

Tonny Kluften

Administrator
Widgets?

The first step to setting this up is to register the widget area for the index insert. Open up your functions.php file again and insert this similar code:
view source
print?
01 <?php
02 register_sidebar( array(
03 'name' => 'index-insert',
04 'id' => 'index-insert',
05 'before_widget' => '<div id="%1$s" class="%2$s widget">',
06 'after_widget' => '</div>',
07 'before_title' => '<h3 class="widget-title">',
08 'after_title' => '</h3>'
09 ) );
10 ?>

To set it up on your main index page, you’ll need to open up the index.php file of your theme, locate the “endwhile” near the end and put the following code directly above it, so that it looks like this.
view source
print?
1 <?php if ($count==2) { ?>
2 <?php dynamic_sidebar('index-insert') ?>
3 <?php } ?>
4 <?php $count = $count + 1; ?>
5 <?php endwhile; ?>

The above code will insert the “index-insert” widget area right after the second post. You can change the $count==2 number to something else, according to the post you’d like the widget area to be displayed after.
 

Tonny Kluften

Administrator
Denne har jeg bukt for lenge siden, funket bra da: Show AdSense Ads After First or Every Post in Wordpress Blogs [How-To]

1. Go to WordPress Dashboard >>Design >> Theme Editor.

2. Click on index.php or Main Index Template file. It will open in Theme Editor on left.

3. Find a line:

<?php while (have_posts()) : the_post(); ?>

4. Add before it:

<?php $adcount = 1; ?>

5. So final code will look:

<?php $adcount = 1; ?>

<?php while (have_posts()) : the_post(); ?>

6. Now find:

<?php endwhile; ?>

7. Add before it:

<?php $adcount++; ?>

8. So final code will look:

<?php $adcount++; ?>

<?php endwhile; ?>

9. Now inside loop, i.e. after “while” line but before “endwhile” line put your AdSense codes. Exact location depend on your choice between ads before post, ads after post, etc. Important thing is you have to put your AdSense code in a if-block. below is an example…

<?php if ($adcount == 1) : ?>

<!-- Put Your AdSense Code here -->

<?php endif; $adcount++; ?>

That’s it. Save changes and check if it works.
Variations…

1. If you want to put ads after first two post…

In step 9 code, Change $adcount == 1 to $adcount == 2

2. If you want to put ads after first three post…

In step 9 code, Change $adcount == 1 to $adcount == 3

3. If you want to put ads after each post…

In step 9 code, Change $adcount == 1 to $adcount == 3. Yes this is same like above. Because AdSense only allows maximum three ad-units on a a single page. This way you avoid blank space created after each post when you directly put AdSense code after each post.
 
Topp