Hi,
I posted this also in the Wordpress formus so if you saw it there then please disregard it here.
I am new to developing themes and have run into a snag which I am not sure how to troubleshoot or fix.
In my functions.php I have put:
function quickchic_widgets_init() {
register_sidebar(array(
'name' => sprintf(__('A_%d'), $i )
,'id' => 'widget_$i'
,'before_widget' => ''
,'after_widget' => ''
));
}
add_action( 'init', 'quickchic_widgets_init' );
In my header.php I have the following snippet of code:
<div id='header_background'>
<?php dynamic_sidebar( 'A_0' ); ?>
<?php dynamic_sidebar( 'A_1' ); ?>
</div>
When I am in the Widgets Admin I can drag any plugins to either ‘A_0’ or ‘A_1’. Say I drag the Text plugin to ‘A_0’, it displays, I type:
<em class='header_img'></em>
<em class='logo'></em>
I then save. I then go to the user site and it shows that this has been pushed over. However if I refresh the Widgets Admin page then the text widget is gone, and the A_0 widget still shows.
It is like it is always setting it to a new instance and not saving existing instances?
I tested this with other widgets including Calander, Enhanced Text, and Links - all with the same result.
Can you point me in the right direction.
Steve
Interestly, If I enable assessibility mode then I assign a plugin to the a_0 widget then save. It does retain the instance even with refreshing the Widget Admin; however there is not way to edit what was originally set. This is true even shutting off assessibility mode the assigned plugin does not show as associated with the a_0 widget, and there is not a way to edit it in assessibility mode; just add and inactive functionality is available.
Hi,
I got this working but I needed to make a small change.
Here is my function.php code for the widget:
function quickchic_widgets_init() {
/* register_sidebar(array(
'name'=> sprintf(__('a_%d'), $i )
,'id' => 'widget_$i'
,'before_widget' => '<div id="%1$s" class="widget %2$s">'
,'after_widget' => '</div>'
,'before_title' => ''
,'after_title' => ''
));*/
register_sidebar( array(
'name' => __( 'Top Left', 'ciia' ),
'id' => 'sidebar-1',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => "</div>",
'before_title' => '',
'after_title' => '',
) );
}
You can see the new register_sidebar() ‘Top Left’ and you can see the more generic function of register_sidebar() sprintf(__(‘a_%d’), $i ) that I have commented out.
Then in header.php the relevant widget code is:
<div id='header_background'>
<?php dynamic_sidebar( 'Top Left' ); ?>
</div>
Now when I add plugins to this widget it works; it saves.
I believe this was a problem with generic function that I had.
Hope this helps.
Steve
Hi James,
I have not really found the answer to this yet, but as I mentioned there is a workaround that actually publishes the desired content of plugins in widgets, but does not allow you to go back and edit it and is quite difficult to remove, so you can re-add it to update changes. Sounds sexy doesn’t it 
I depends on the version of Wordpress you are using but as of 3.2 you need to:
- Log into the admin
- Go to Widgets
- At the top right of the page see ‘Show Options’ - Select this
- See the option ‘Accessibility Mode’ and turn it on
- Go back to your Widget and try to re-ad the Google Ads code
You need to make sure that the Google Ads code is a plugin for this to work.
Alternatively you could code it directly into the Wordpress theme you are using, but I don’t know how comfortable with this?
Regards,
Steve
hi serverstorm,
i am running a classified ads wordpress blog and tried to add my my google ads code in theam widgets but not save the changes.plz help me