Remove […] from RSS feed?

Here’s a suggestion: First we target the RSS widgets that have summaries. Then we filter the output of wp_trim_words() within the wp_widget_rss_output() function, to remove the […] part. Then we clean up in two ways: First we remove our wp_trim_words() filter, if it’s running, before the current widget is displayed. We can do that by … Read more

How to use control_callback when creating a widget via functions.php or plugin?

Actually the from fields only should be in the control_callback function , both form and handling so try this: <?php /* Plugin Name: custom dashboard widget Plugin URI: http://en.bainternet.info Description: custom dashboard widget with control form Version: 0.1 Author: bainternet Author URI: http://en.bainternet.info */ //show widget function custom_dashboard_widget_coach() { //get saved data if ( !$widget_options … Read more

How to register custom menu widget

Try this code (in function.php) class MyWidget extends WP_Widget { function __construct() { $widget_ops = array( ‘description’ => __(‘Use this widget to add one of your custom menu as a link list widget.’) ); parent::__construct( ‘custom_menu_widget-1’, __(‘My name’), $widget_ops ); } function widget($args, $instance) { // Get menu $nav_menu = ! empty( $instance[‘nav_menu’] ) ? … Read more

Delete Custom Dashboard Widgets

The built-in dashboard widgets are not marked somehow, you have to use a fixed list: ‘dashboard_right_now’, ‘dashboard_plugins’, ‘dashboard_quick_press’, ‘dashboard_recent_drafts’, ‘dashboard_recent_comments’, ‘dashboard_incoming_links’, ‘dashboard_primary’, ‘dashboard_secondary’ So your code should test if the current widget is in that list and remove the widget, if it isn’t: add_action( ‘wp_dashboard_setup’, ‘t5_remove_custom_dashboard_widgets’, 11 ); function t5_remove_custom_dashboard_widgets() { global $wp_meta_boxes; $builtin = … Read more

Add div class to only one widget

You have two possible solutions. 1. The widget_display_callback filter hook This filter hook parameters allows you to target easily the widget instance and override it’s arguments. A possible approach would be: Inside the filter callback, modify the arguments for that instance, display it and then return false to prevent it from being displayed again the … Read more

Widget Update Code Not Working

You’re using get_field_id() for the name attribute of the form elements, but you should use get_field_name(). The field names are of the form widget-{$id_base}[{$number}][{$field_name}], but id’s can’t use [], so they are like widget-{$id_base}-{$number}-{$field_name}.

Widget with random posts from a blog for external sites

To create a special output of random posts: Register an endpoint to the root of your blog. See A (Mostly) Complete Guide to the WordPress Rewrite API for details. Refresh the permalink settings. I would do this on (de)activation only. Hook into ‘template_redirect’ and return your output depending on the details of the requested endpoint. … Read more