Ok, so we are using an Ad manager and are looking to place a banner ad every 6 events when you are viewing as a list (as the main events page or even in a category). So if there are 18 events, we want to have a ad show up between 6th and 7th events and 12th and 13th events. All I need to do is make this code <?php echo do_shortcode(“[sam id=10]”); ?> appear every 6th event that is listed? Anybody want to take a stab? Appreciate it!
Obviously you would need to either add more multiples of 6 into the if statement or come up with a better alternative, but this basically counts the events posts and inserts the data every 6 posts.
You can use Modulus division to add in every Nth (in this case 6th) instance. So…
if($i== 6 || $i== 12 || $i== 18)
would be
if($i % 6 == 0)
One pitfall with this is that 0 % 3 = 0 so with the counter ($i) starting at 0 you’ll could also get an ad at the beginning of the loop. Deans example adds 1 to $i before the first iteration of the loop anyway so that shouldn’t be an issue. But just in case, to stop that you can use.
Interesting! I will try this now. Now what about adding this function into your themes functions.php file so that you can update the plugin without overwriting the customization? Would you think that is possible?
Well if you copy the event_list.php and event:list_display.php to the wp-content/uploads/espresso/templates directory and edit them there, any updates will not over write the changes.
I believe that now you can also copy those files to your theme folder as well, with similar results.
The only caveat is if the update brings changes to the template files then you will need to update you modified files with those changes.
Viewing 6 reply threads
The support post ‘Inputting ads into event list.’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.
Support forum for Event Espresso 3 and Event Espresso 4.