Override custom menu widget

Ok, here we go. I extended the default Navigation widget for you. Add this to your themes functions file. After you have done this, go to widgets in your dashboard and you will see a widget called ‘Matt Royal Custom Menu’ now. Use this one. In the below code, the div class has been added … Read more

How to retrive widget title/data

Found a ‘dirty’ way to do it: Here’s my code: $sidebar_id = ‘sidebar1′; $sidebars_widgets = wp_get_sidebars_widgets(); $widget_ids = $sidebars_widgets[$sidebar_id]; foreach( $widget_ids as $id ) { $wdgtvar=”widget_”._get_widget_id_base( $id ); $idvar = _get_widget_id_base( $id ); $instance = get_option( $wdgtvar ); $idbs = str_replace( $idvar.’-‘, ”, $id ); echo ‘<li><a href=”#’.$id.'”>’.$instance[$idbs][‘title’].'</a></li>’; }

Add thumbnail to recent posts widget using filters

Here’s one way to do it through the the_title filter. We can limit the scope to the Recent Posts widget, by initialize it within the widget_posts_args filter and then remove it again after the loop. /** * Recent Posts Widget: Append Thumbs */ add_filter( ‘widget_posts_args’, function( array $args ) { add_filter( ‘the_title’, ‘wpse_prepend_thumbnail’, 10, 2 … Read more

Can I ignore caching of a plugin in W3 Total Cache? [closed]

You can try fragment caching, from plugin’s FAQ: Edit your templates to with the following syntax to ensure that dynamic features remain so: Example 1: <!– mfunc any PHP code –><!– /mfunc –> Example 2: <!– mfunc –>any PHP code<!– /mfunc –> Example 3: <!–MFUNC –> echo rand(); <!–/mfunc –> Example 4: <!– mclude path/to/file.php … Read more

How to add class on Widget Title

Two approaches: Don’t bother Just target .widget.{dynamic-class} h3 instead Use %2$s I don’t know if this will work, but try: ‘before_title’ => ‘<h3 class=”%2$s”>’ But personally, I’d go with the former option. You’ve already got a unique class name; just leverage the element hierarchy to apply styles selectively.

Display all posts with same title

Lets use the build in features WordPress has to offer. It is almost always not adviced to use custom SQL whenever WordPress offers native functions to perform the specific duty. To query our posts, we will make use of WP_Query. The only problem is, WP_Query does not support the feature where we look for posts … Read more

Adding classes to dynamic sidebar

You haven’t actually said what the problem is. But I can see one for starters – dynamic_sidebar in your if conditions will echo out the widgets immediately. If you want to check a sidebar has widgets, use is_active_sidebar: is_active_sidebar( ‘sidebar-1’ ); // True/false

WordPress widget in custom theme

You have to hook your widget registering like that: add_action(“widgets_init”, “register_widgets”);// Hook WP /** * Register widgets */ function register_widgets() { require_once “FooWidget.php”; register_widget(“FooWidget”); } Same for the widget zones add_action(“widgets_init”, “register_widgets_zones”); function register_widgets_zones() { register_sidebar(array( “name” => “Foo Zone Page”, “id” => “foo-zone-widgets”, “class” => “panel”, “before_widget” => ‘<div id=”%1$s” class=”widget %2$s”>’, “after_widget” => … Read more