dynamic_sidebar( $index );
]]><?php if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(“My Widget”) ) : ?>
<?php endif;?>
And in the function:
if ( function_exists(‘register_sidebar’) )
register_sidebar(array(
‘name’ => ‘My Widget’,
‘before_widget’ => ‘<div class = “My Widget”>’,
‘after_widget’ => ‘</div>’,
‘before_title’ => ‘<h3>’,
‘after_title’ => ‘</h3>’,
)
);
?>
The new widget is created and I can find it in the back-end of my website.
In this widget I have put my polylang’s flags, but it has created an empty section in the header (I would like to have it at the right side with vertical alignment), in this empty section all flags work correctly, but if I try to move it through CSS only italian language is available, the other flags collapse their link… What can I do? Please and Thanks!
Paola
I’ve been stuck with this issue for some time and thought maybe someone can help.
I have this in my functions.php:
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => __('Footer', 'textdomain')
));
and a .po and .mo files that translate the word ‘Footer’ to another language.
But when I use this code in the template file:
dynamic_sidebar( __('Footer') );
all I get is the dynamic sidebar content for english, although the option is set to display the widget in “All languages”.
If I use this code:
dynamic_sidebar( __('Footer') );
dynamic_sidebar( __('Footer in another language') );
it works, but then I would have to add one line for every language, and if somebody should change the translation files, it would stop working.
Am I doing something wrong?
Or maybe it is a bug?
Thank you!
https://www.ads-software.com/plugins/polylang/
]]><?php
if(!dynamic_sidebar('my-conditional-widgets'))
$class = "has-no-widgets"; ?>
<div id="myDiv" class="myClass <?php echo $class; ?>">
however, it seems dynamic_sidebar() always returns true. I guess it might be because it’s not *really* empty, but turns out empty due to the plugin conditions.
Is there a better way to know if there are no widget to display?
Thank you in advance for any help.
https://www.ads-software.com/plugins/conditional-widgets/
]]>if(!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer'))
if(function_exist('dynamic_sidebar) || dynamic_sidebar('Footer'))
Could you tell me why in this case was used !function_exist OR !dynamic_sidebar?
And where can I find function_exist and dynamic_sidebar references?
<?php dynamic_sidebar(); ?>
don’t work.
I’ve played with the settings and can get it to see the block by disabling the HTTP request, but the block still won’t show up even after clicking the page refresh.
Once I remove the dynamic_sidebar
code, it functions properly. This isn’t the entire template, but “Second Content Block” works just fine. “About Us” does not show up when editing the page with default settings, nor can I get it to work checking the MCB settings.
`<section id=”guest-list” class=”guest-list”>
<div class=”container”>
<div class=”content”>
<?php the_block( “Second Content Block”, array() ); ?>
</div>
<aside class=”sidebar”>
<ul>
<?php dynamic_sidebar(‘sidebar_default’); ?>
</ul>
</aside>
</div>
</section>
<div class=”container”>
<div class=”content”>
<?php the_block( “About Us”, array() ); ?>
</div>`
I tried searching, but couldn’t find anything related. Any help would be appreciated!
https://www.ads-software.com/plugins/multiple-content-blocks/
]]>This is about customized sidebar management.
I just found this nice piece of code which automatically creates an individual sidebar for each category page. It’s a simple copy&paste but necessary to read to understand the problem, I guess.
Though I’m not really confident with PHP, I suspect the problem in the following step. In the sidebar.php template he wants me to replace
dynamic_sidebar($sidebar);
with
dynamic_sidebar( $sidebar_id );
With this, the whole thing takes effect: The new sidebars are shown in the “Widget” toolbox and they appear on the actual category pages as well. But by doing it, all the other sidebars (from startpage, any other page, single-post-view etc) simply disappear. Switching around in the Theme Options etc doesn’t help here. The other way around: when I remove the _id
again, the sidebars for the category pages are set back to the default “Primary” sidebar, the sidebars I adjusted via GUI reappear and the code has no effect.
My very wild guess: the $sidebar_id
is defined via category IDs and is just not put into effect if there is no category ID which can be prompted … but as I said, I hardly know anything about PHP syntax.
My questions are: Is there a workaround for this? I don’t really need the sidebars to be shown on regular pages (would be nice, though) but the frontpage is too boring without the sidebar… Is there a possibility to add something like a condition that forces a certain sidebar if the page is NOT a category page?
]]>register_sidebar( array(
'name' => 'Frontpage Widgets',
'id' => 'frontpage-widgets',
'description' => '',
'before_widget' => '<div class="col">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>',
));
Then, I’ve got the render of that sidebar somewhere in my template:
<?php dynamic_sidebar('frontpage-widgets'); ?>
Once I’ve put some widgets inside that sidebar, from the backend of WordPress, how can I customize/change the render of this specific sidebar?
Which hook should I use or override to achieve that?
I’d like, for istance, to render all widgets within that sidebar in groups of three. Maybe wrapped in a <div class="row">
.
Thanks to all!
]]>Starting from this: https://wpsell.net/cart66-and-wp-super-cache-making-them-dance/, I followed those instructions exactly, including all the WPSC settings in the Advanced tab but using the mfunc tags were simply not working and my widget cart was still being cached.
The most important settings to get this working:
– you must use PHP caching (NOT mod_rewrite)
– Enable dynamic caching MUST be checked
– Late Init MUST be checked
At that point I realized that I was using a dynamic_sidebar(); call instead of get_sidebar(); so I tried using the dynamic-cached-content tags instead and finally – SUCCESS! The formatting of these is a little different than the mfunc tag so see this example of what I used:
<!--dynamic-cached-content-->
<?php dynamic_sidebar('widgetcart'); ?>
<!-- dynamic_sidebar('widgetcart'); -->
<!--/dynamic-cached-content-->
Note the second commented php call AFTER the initial call – which is the opposite of the mfunc tag format. Also note that for both dynamic-cached-content and mfunc tags, when you include the php code in comments, make sure to leave out the php tags:
WRONG: <!--mfunc <?php get_sidebar(); ?> --> <?php get_sidebar(); ?> <!--/mfunc-->
RIGHT: <!--mfunc get_sidebar(); --> <?php get_sidebar(); ?> <!--/mfunc-->
WRONG: <!--dynamic-cached-content--><?php dynamic_sidebar('widgetcart'); ?>
<!-- <?php dynamic_sidebar('widgetcart'); ?> --><!--/dynamic-cached-content-->
RIGHT: <!--dynamic-cached-content--><?php dynamic_sidebar('widgetcart'); ?>
<!-- <?php dynamic_sidebar('widgetcart'); ?> --><!--/dynamic-cached-content-->
I hope this helps some people.
Now, if someone could take the example here https://ocaoimh.ie/2013/05/01/mfunc-in-wp-super-cache-1-4-and-beyond/ and apply it to dynamic widget content. While it seems pretty straightforward, I couldn’t get my head around it.
https://www.ads-software.com/plugins/wp-super-cache/
]]>