How to call widget by widget’s id?

You can display the specified widget using the_widget. It takes the class name of the widget as an argument (not ID), so you’ll need to know that info to use it, but this allows you to use a widget outside the sidebar. If you’re looking to run some code based on the presence of a … Read more

How do I create a widget to embed the code for a sign up form, so that the sign up form appears on every page?

It’s not necessary to create a Widget, just enable the Shortcode capability to the default Text widget. Add this to the child theme’s functions.php: add_filter(‘widget_text’, ‘do_shortcode’); Then you can proceed to create a Shortcode that will render the form. See: How do I create shortcodes for my wordpress themes? The appearance of the Widget in … Read more

How to stop comments widget conflicting with theme comments

You could do this much simpler like this: <?php $comments = get_comments(‘status=approve&number=5′); ?> <ul> <?php foreach ($comments as $comment) { ?> <li> <?php echo get_avatar( $comment, ’35’ ); ?> <a href=”<?php echo get_permalink($comment->ID); ?>#comment-<?php echo $comment->comment_ID; ?>” title=”on <?php echo $comment->post_title; ?>”> <?php echo strip_tags($comment->comment_author); ?>: <?php echo wp_html_excerpt( $comment->comment_content, 35 ); ?>… </a> </li> … Read more

Programmatically add widgets to sidebars

When I started this answer it should be just a small note. Well, I failed. Sorry! Stay with me, there is a goody hidden deep down … How WordPress widgets are stored The list of widget is stored in an option named ‘sidebars_widgets’. A var_export() may give something like the following: array ( ‘wp_inactive_widgets’ => … Read more

Simple widget causing whitescreen

register_widget( ‘latest_mag_issues_widget’ ); should be register_widget( ‘latest_mag_issue_widget’ ); Update After fixing that though, there are a couple of other errors. Here’s the complete updated copy of your code that I could get working: class latest_mag_issue_widget extends WP_Widget { function latest_mag_issue_widget() { $widget_ops = array( ‘classname’ => ‘widget_latest_issues’, ‘description’ => ‘Latest Mag Issues Widget for Media24 … Read more

Dashboard widget custom positioning?

The dashboard widget function wp_add_dashboard_widget() is just a wrapper for add_meta_box(). So you can use the underlying function instead. add_meta_box( ‘my_comments_user_dashboard_widget’ ,’My comments’ ,’dashboard_user_comments_widget_function’ ,$screen // Take a look at the output of `get_current_screen()` on your dashboard page ,’normal’ // Valid: ‘side’, ‘advanced’ ,$priority // Valid: ‘default’, ‘high’, ‘low’ );