Different widgets in sidebar on sub-children pages?

I use Widget Logic at my blog. It is not most convenient solution around, but definitely one of the most flexible. Widgets can be displayed/hidden based on arbitrary PHP condition. Works great with conditional tags and when that is not enough you just write your own conditions and use them.

Filter Text from sidebar widget?

In the method “widget” look for the line that sets the category then add either: $cat = empty($instance[‘cat’]) ? ‘N/A’ : $instance[‘cat’]; (where you replace N/A with something you like) or… better… add a filter instead like this: $cat = apply_filters( ‘widget_my_cat’, empty($instance[‘cat’]) ? ‘N/A’ : $instance[‘cat’], $instance, $this->id_base); And then hook into ‘widget_my_cat’ to … Read more

How to load a stylesheet into wp_head from a custom widget?

There are various approaches (including this one), but you could consider, since you’re talking about a stylesheet and not a script, simply enqueueing it from the Plugin, regardless of whether the Widget is active. (Which is worse: the few bytes of Widget-specific CSS, or the server overhead to determine if the Widget is active?) Just … Read more

Is there a simple way to have a new sidebar for each page?

Registering sidebar is just a function call, there is no reason it can’t be run on top of some logic. Here is code I wrote (and use) in my current theme: $pages = get_pages(); foreach ( $pages as $page ) { register_sidebar( array( ‘name’ => “Page: {$page->post_title}”, ‘id’ => “sidebar-page-{$page->post_name}”, ‘description’ => “Widgetized area after … Read more

change widget to display excerpt instead of content

I dont see anywhere on the code that it adds either full text or excerpt. So I decided to test the widget and that’s exactly what I got. There is no post content being output. So my suggestion is to just add <?php the_excerpt(); ?> Wherever you want it to output… eg just after the … Read more

Adding a WordPress Widget to a settings page

You would call: add_meta_box( $widget_id, $widget_name, $callback, $screen->id, $location, $priority ); Where the screen ID is obtained via: $screen = get_current_screen(); Then display each location e.g. : do_meta_boxes( $screen->id, ‘column3′, ” ); Here’s the dashboard function that displays the dashboard: function wp_dashboard() { global $screen_layout_columns; $screen = get_current_screen(); $hide2 = $hide3 = $hide4 = ”; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)