WP Bannerize
[resolved] Add container before and after images (5 posts)

  1. brightweb1
    Posted 3 years ago #

    I know how to set html tag before and after a banner. But, how can I wrap my entire list?


    <li>Banner 1</li>
    <li>Banner 2</li>
    <li>Banner 3</li>



  2. gfazioli
    Plugin Author

    Posted 3 years ago #

    just use before and after settings (container_before e container_after too) in PHP code o Widget options.

    For example, the code below:

    <?php wp_bannerize('container_before=<div>&container_after=</div>&before=<span>&after=</span>'); ?>

    Output will be:

    <span><a href=".."><img src="..." /></a></span>
    <span><a href=".."><img src="..." /></a></span>


  3. brightweb1
    Posted 3 years ago #

    Not work for me =/

    I followed your instruction and use this code in template:

    <?php wp_bannerize('container_before=<ul>&container_after=</ul>&before=<li>&after=</li>'); ?>

    But the final result is:

    <div class="wp_bannerize ">
    <li><a href=".."><img src="..." /></a></li>

    Am I doing something wrong? Thanks

    [ Please do not bump, it's not permitted here. ]

  4. astockwell
    Posted 3 years ago #

    I'm having the same problem as @brightweb1, I just downloaded v3.0.62 with WordPress v3.4.2, and the container_before and container_after attributes do not change the output, it is still

    <div class="wp_bannerize Home Page Banners">

    Even when they're set to <ul> and </ul>, respectively.

    Any help is much appreciated!

  5. astockwell
    Posted 3 years ago #


    I noticed deep in the plugin readme files that the container_before and container_after attributes have been deprecated. This is unfortunate, but as a result I've built a work-around function that I hope helps people:

    //Customize wp_bannerize plugin html output
    function custom_bannerize($group_name) {
    	if( function_exists( 'wp_bannerize' )) {
    		global $wpBannerizeFrontend;
    		// Setup args as you would for normal wp_bannerize() call
    		$bannerize_args = 'group=' . $group_name . '&before=<li>&after=</li>';
    		// Get result of initial bannerize call (without the default 'echo' call) via %plugins_dir%/wp-bannerize/Classes/wpBannerizeFunctions.php
    		$str_banners = $wpBannerizeFrontend->bannerize( $bannerize_args );
    		// Replace container elements with desired ones
    		$str_banners = str_replace(array('<div class="wp_bannerize ' . $group_name . '">','</div>'), array('<ul class="myClasses">','</ul>'), $str_banners);
    		// Remove hardcoded <img> tag height & width params (OPTIONAL)
    		$str_banners = preg_replace('/(width|height)="\d+"(\s|)/', '', $str_banners);
    		return $str_banners;
    	} else {
    		return false;

    It's unfortunate that these were deprecated as it removed a significant amount of versatility from the plugin. I don't know the circumstances of the removal but I would encourage that they be reinstated in the plugin (or at least removed from all readmes on wordpress.org).

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Bannerize
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic