Site logo

Archived topic

Banner between post

2 replies · Started by Anonymous on May 30, 2015

Viewing posts 1–3 of 3

Hi

If i would like to add a banner code so a banner is show between every post is that possible? And if what file do i need to edit? Or is it any good add-ons for this?

Hey Tobias, you can achieve that doing this:

I'll assume that you are using a child theme. So, in the GeneratePress folder, find the file "index.php", copy and paste into your child theme folder.

Open the "index.php" and search for this:

<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>

Replace for this:

<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php $count = 1; ?>

Find this now:
<?php endwhile; ?>

Replace for this:

<?php if ($count == 1) : ?>
DO YOUR STUFF IN HERE
<?php endif; $count++; ?>
<?php endwhile; ?>

Maybe this could help you mate!

You might be able to achieve this using a function.

Assuming you want your banner to show up after every single post in your blog/archives etc..

add_action( 'generate_after_entry_content','generate_insert_banner' );
function generate_insert_banner()
{ 
      // If we're on a single post, don't do anything
      if ( is_single() )
            return;
?>
      Put your banner code in here!
<?php }

How to add PHP: http://generatepress.com/knowledgebase/adding-php-functions/

This archived topic is closed to new replies.