Connect with us

Tips & Tricks

Adding a external file after the first post

How might you display a Google ad after the first post or anything you like? It is very simple. You just need to add the variable $loopcounter in the Loop. If the $loopcounter is less than or equal to 1, then include your option. Check out the code:

<?php if (have_posts()) : while (have_posts()) : the_post(); $loopcounter++; ?>

  // your loop

  <?php if ($loopcounter <= 1) { include (STYLESHEETPATH . '/you-file.php'); } ?>

<?php endwhile; ?>

<?php else : ?>

<?php endif; ?>

Pretty simple huh. Well in the $loopcounter line, you may change the include to point to any file or maybe a custom widget like so:

<?php if ($loopcounter <= 1) { dynamic_sidebar( 'Plus Post' ); } ?>

Or use your code directly in between the { & }.

Random Search Terms

Title

Top Articles

Top Searches

powered by WassUp

Recent Posts: Fully Net Worth . com

1TakeJay Net Worth: How Rich is the Rapper Actually?

1TakeJay Net Worth: How Rich is the Rapper Actually?

1TakeJay is an American rapper who is from Compton, California. Some of his popular songs include “I Like Bi!tches”, “Arco”, and “I Know”. As of 2019, 1TakeJay net worth is estimated to be $300,000. His mother was a fan of the rap genre and as a result, from a very young age, Jay was exposed […]

Matt Farah Net Worth: How Rich is the Car Enthusiast Actually?

Matt Farah Net Worth: How Rich is the Car Enthusiast Actually?

Matt Farah is an American YouTube personality and businessman. He is known for reviewing famous cars on his YouTube channel. As of 2019, Matt Farah net worth is estimated to be $1.5 million. Matt was born on December 1, 1981, in New York City. He attended the University of Pennsylvania where he studied Bachelors of […]

David Bellamy Net Worth: How Rich was the English Botanist?

David Bellamy Net Worth: How Rich was the English Botanist?

David Bellamy was an English author, broadcaster, botanist, and environmental campaigner. David Bellamy net worth at the time of his death is estimated to be $5 million. Bellamy was born on January 18, 1933, in London to parents Thomas Bellamy and Winifred May Bellamy. As a child, he wanted to become a ballet dancer, but […]