Archive for September, 2007

Wanna Buy Some Blogs?

Friday, September 7th, 2007

That’s right you read it correctly. I’m looking to sell a few of my blogs. I’ve had some people interested in buying several of the blogs in my blog network and I figure I could definitely use the money to fund other ventures that I’m currently working on.

Just some quick notes. The following blogs all make between $40 and $100 a month, I write nothing for any of them (aka all passive income). All have great domain names, have been around for over a year, are all PR4 and all need a good home. I just don’t have time to create content for them anymore.

I’ll write more about them later but here are the ones I’m thinking of parting with.

RumorPatrol.com
FinancingWealth.com
BlogSilver.com
SprintRants.com

Comment or contact me via email evossman at gmail .com

Multiple Adsense Between Paragraphs in Wordpress Blog Posts

Wednesday, September 5th, 2007

I’ve been a way for a while, trying to regain some focus in my life and thought I would return to this blog by providing some tips while using Wordpress. My most recent jump into playing with php and Wordpress is how to add Adsense code within blog posts in between paragraphs on every post.

I searched around and only found some plugins here and there that limit where the Adsense code can go. So I decided to build my own little php code. This should allow you to deal with the “” tag as well.

For this I’ve just dealt with the single.php file but you can put this wherever you’d like. Just remember the limits you have on the number of adsense blocks you can put in.

OK, so it’s really simple. Where you see <?php the_content(); ?>. Just replace that with:

<?php
$content = apply_filters(’the_content’, $post->post_content);
$save = explode(”</p>”, $content);
$count = 1;
foreach ($save as $a){
if ($count == 3){
echo’
<div style=”margin: 5px 0px 5px 0px; text-align: center;”>

YOUR ADSENSE CODE HERE

</div>’;
}
echo $a.”</p>”;
$count = $count + 1;
}
?>

It’s that simple! You can play around with the foreach and the if statements to insert your adsense between different paragraphs, multiple if statements allow for multiple inserts between multiple paragraphs. You can use if in_category to display ads a certain way if they’re in a certain wordpress category. The list is endless.

Now, for those of you who actually want to know how this works here goes:

The first line

$content = apply_filters(’the_content’, $post->post_content);

pulls your content into a string into the variable $content. This includes all code, html or otherwise. Don’t ask me why the apply_filters was needed. All I can tell you is that I wasn’t able to do it any other way.

Next we chop up the string into an array split up by </p> using the explode function.

$save = explode(”</p>”, $content);

As long as you are using paragraph tags in your posts (some people choose to take them out) then this will work. Each array value will be a separate paragraph.

Then we initialize a counter to keep track of how many paragraphs we echo (to come later),

$count = 1;

We then start our foreach loop to loop through each value in the array $save.

foreach ($save as $a){

Then we check to see what paragraph we’re on. Here is where you can play with it to echo your adsense code wherever you’d like. I have it displaying adsense after the third paragraph but you can display it wherever. Such as, if ( $count == 1 || $count == 3) would display before and after. You can use elseif to display different adsense layouts at different points in the post. Be creative. Notice that I’ve also decided to center my code using an inline style.


if ($count == 3){
echo’
<div style=”margin: 5px 0px 5px 0px; text-align: center;”>

YOUR ADSENSE CODE HERE

</div>’;
}

We then print our array value $a remembering to add a </p> at the end because php explode, explodes the array but removes the value we told php to explode from.

echo $a.”</p>”;

Finish that off with an increment of the $count variable and you’re done!

$count = $count + 1;
}
?>

This should give you the bare bones to insert adsense code into anywhere you’d like that you are displaying content. I use it only in single.php on my wordpress blog. You can see an example at my Hawaii Blog in this popular article about Dog the Bounty Hunter headed to Jail in Mexico.

Hope it helps some people out. Spread the word if you know anyone who can benefit from this.