WordPress: Adding Code to Front Page-Only Between Posts

WordpressHow to Add Code below your Home Page Blog posts?
How to ad Adsense code below Front Page Blog Postings
How do I add HTML to My Twenty Ten Theme Front Page (below posts)?
How to Add code to Front page and not the rest of my blog?

This code is used to place and code (or ad code…whatever you’d like) on your WordPress blogs front page only

(You can also have it appear sitewide, if you follow additional notes below)

(This code is used only for one placement on your front page ) (more than 1 placement lessons to come soon!)

SEE EXAMPLE:

code-below-posts

1- Open up LOOP.PHP

2- Find this piece of code in LOOP.PHP

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

3- Place the following code segment right ABOVE it

<!– CODE added to place in CODE addin onto front page only –>
<?php $postnum = 1; $showads = 3; ?>
<!– end CODE added to place in CODE addin onto front page only –>

4- Note:
This is set up to place the code after  your third blog post 3, if you want to change that, then change 3 to another number  (Example: =5)

5- Great! Now onto the 2nd part

_________________________

6- Find this code in LOOP.PHP (closer to the bottom)

<?php endif;

7- Place the code listed below right ABOVE it
(though erase the part that says “ERASE THIS LINE AND PLACE YOUR CODE HERE” and place in your desired code

 

<!– CODE part 2 added to place CODE addin –>
<?php if (is_front_page()) { ?>
<?php if ($postnum == $showads) { ?>

ERASE THIS LINE AND PLACE YOUR CODE HERE

<?php } $postnum++; ?>
<?php } ?>
<!– END – CODE part 2 added to place CODE addin–>

8- That’s it!
______________________________________________________

What if I want this on every POST, ARCHIVE and HOME PAGE?
A:  Use the following code instead (as noted in step #7)

<!– CODE part 2 added to place CODE addin –>
<?php if ($postnum == $showads) { ?>

ERASE THIS LINE AND PLACE YOUR CODE HERE

<?php } $postnum++; ?>
<!– END – CODE part 2 added to place CODE addin–>

______________________________________________________

Related Posts Plugin for WordPress, Blogger...

About Michael Bohatch - SimpleInbound

Michael Bohatch has been involved with SEO and Inbound Marketing since its inception. Michael provides professional services that combine his experience in Web Analytics, SEM, SEO and Inbound Marketing for a comprehensive strategic approach to web optimization. SimpleInbound.com is an advice blog where he documents some of his findings.
This entry was posted in Wordpress and tagged , , . Bookmark the permalink.
If you would like to stay current on our Inbound Marketing Techniques, make sure to:
Subscribe to the RSS Feed!

Leave a Reply

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

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