• This plugin has a bug (in my opinion). The widgets aren’t displayed at the point where you put the short code, but always at the beginning of the post/page.

    I found the following fix: download the plugin, unzip it and open addw2p.php

    Find the following function:

    function addw2p_register($atts, $content)

    and substitute that function with this:

    function addw2p_register($atts, $content) { //put widgets in enteries.
    	extract(shortcode_atts(array(
    		'name' => '1'
    	), $atts));
    	if ( $name == 1) return $content;
    	$title = "addw2p-".$name;
    	$names = get_option('addw2pdn');
    	$names = explode("|",$names);
    	if( !in_array($name,$names) && $name != NULL ) {
    		array_push($names,$name);
    		foreach ($names as $subname ) {
    			$new_names .= "|";
    			$new_names .= $subname;
    		}
    		update_option('addw2pdn',$new_names);
    	}
    	//show widgets
      ob_start();
    	echo '<ul class="ul-addw2p ul-'.$title.'">'."\n";
    	if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar( $title ) ) :
    		echo '<li>please set some widgets to show from Appearance -> Widgets.</li>'."\n";
    	endif;
    	echo "</ul>\n";
      $myStr = ob_get_contents();
      ob_end_clean();
    	return $myStr;
    }

    Instead of echoing the widgets code directly (which always makes it appear at the beginning) the code is returned, which makes it appear at the position of the short code.

    Now, zip it up again, and you can install it through the ‘upload’ install option in your WordPress admin panel.

    http://wordpress.org/extend/plugins/add-widgets-to-page/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Add Widgets to Page] widgets are always displayed at the beginning – FIX’ is closed to new replies.