Latest/Recent posts widget title link

I’ve updated your widget code to include a new field called “Title Link”. This, along with some additional markup, will create a link around your widget title. You’ll probably need to add better validation to the Title Link field. <?php /** * Widget Name: Recent Posts with Excerpts Widget * Description: A widget that allows … Read more

How to check if searchform.php is being included as widget?

Check if searchform is included? The get_search_form() function (that should be used) uses locate_template(‘searchform.php’); to display the search form. The later returns (as you can see from its source) the template filename if one is located So if you’re just wanting to catch the default way, then you should simply test ‘searchform.php’ === locate_template( ‘searchform.php’ … Read more

duplicate sidebar

Try giving a unique ID to each dynamic sidebar, via the id parameter passed to register_sidebar(): register_sidebar( array( ‘id’ => ‘essential’, ‘name’ => __(‘Essential Plan’), ‘before_widget’ => ”, ‘after_widget’ => ”, ‘before_title’ => ”, ‘after_title’ => ” ) ); register_sidebar( array( ‘id’ => ‘premier’, ‘name’ => __(‘Premier Plan’), ‘before_widget’ => ”, ‘after_widget’ => ”, ‘before_title’ … Read more

How to determine which registered sidebar area a custom widget is loaded into

The information you want is in the $args parameter. var_dump($args); // inside your widget method Look at the ‘name’ and ‘id’ array elements. Your code should look something like: function widget( $args, $instance ) { extract($args); $title = apply_filters( ‘widget_title’, empty($instance[‘title’]) ? ” : $instance[‘title’], $instance ); $text = apply_filters( ‘widget_text’, $instance[‘text’], $instance ); $hide_title … Read more

I need some direction on how to have a sidebar based on meta rather than page

Create a sidebar $type . ‘_sidebar’ Register the sidebar $type . ‘_sidebar’ (e.g dog_sidebar) Pass the type as GET argument to the widget.php (create some menu entries or something else where you link to e.g. wp-admin/widgets.php?sidebar_type=dog_sidebar) Filter out every sidebar that should not be displayed. You can use this function: global $wp_registered_sidebars; $type =filter_input( INPUT_GET, … Read more

nowplaying.include.php Will Not Display Results

Your script is at /wp-content/themes/responsive-child-theme/nowplaying-example.php but you are including /nowplaying-example.php. That is not going to work. You need to provide the complete path for that include: include(get_stylesheet_directory().’/nowplaying-example.php’); Assuming I have read that right, and assuming that the files are actually there. Your other code– the widget code– contains curly quotes. Don’t use those. Use ordinary, … Read more

Ajaxing function in widget class

If this is in a widget class, you need… add_action(‘wp_ajax_my_func’, array($this,’my_func’)); … not just… add_action(‘wp_ajax_my_func’, ‘my_func’); However, I suspect there to be more problems than just that due to the context you are using this in. But without more code, that is all I’ve got. Based on new information in the question… Both your function … Read more

Add ‘Right Now’ widget to custom dashboard

I’ve got to know it in Make WordPress UI. The plugin Dashboard uses a very interesting technique: add_action( ‘load-index.php’, array( $this , ‘override_dashboard’ ) ); public function override_dashboard() { if( !isset( $_GET[‘page’] || ‘custom-dash’ != $_GET[‘page’] ) return; if ( get_current_screen()->in_admin( ‘site’ ) ) { require dirname( __FILE__ ) . ‘/dashboard-override.php’; exit; } } And … Read more

Dashboard Widget Form

That if(‘POST’…) just alone -in the middle of the plugin code- doesn’t seem right. You can hook into load-$pagenow and process the form submission there: add_action( ‘load-index.php’, ‘check_posted_data’ ); function check_posted_data() { if( ‘POST’ == $_SERVER[‘REQUEST_METHOD’] && !empty( $_POST[‘my_prefix_message’] ) ) { wp_die( “I’m here! {$_POST[‘my_prefix_message’]}” ); } } Please note that you’re missing security … Read more