Sidebar widget: Randomly select text from a given set
The plugin repository contains a few options that you could use. At a glance this one looks promising.
The plugin repository contains a few options that you could use. At a glance this one looks promising.
By what code you’ve posted, it seems like you’ve got a secondary loop set up (using a WP_Query object). So to display the current’ posts tags you can use: the_tags – to print a list of the post’s tags wp_tag_cloud – to print a tag cloud. get_the_tags – to return an array of tag objects, … Read more
well first of all, is_plugin_active takes the name of the plugin sub-directory/file, so passing it a classname won’t work. I’m not sure why you’re passing anything widget related if you’re checking for plugins your widget depends on. other options are php’s class_exists and function_exists to check if plugin functions your widget uses exist. check in … Read more
the_post_thumbnail(); function is not supposed to be echo-ed! get_the_post_thumbnail(); is meant for that. Refer to the linked WordPress Codex pages. Try this instead: <?php // Wraps post-thumbnail in li tags echo ‘ <li>’ . get_the_post_thumbnail(‘talent-featured-thumb’) . ‘</li>’; ?>
Depending on what you want you’ll need to use the the_widget function, I believe there are few examples of using it in the WordPress twentyeleven theme as well.
Short explanation The $wpdb->prepare() method works similar to sprintf()/printf() and therefore needs more than one argument (else it’s senseless to use it at all). So if one of your plugins or the theme makes a DB call, which is prepared to protect you against cross script attacks and similar and doesn’t do it properly, WordPress … Read more
You can use the filter widget_title and a “virtual” shortcode. Of course, as One Trick Pony points out, the “why” (and the “what”) is essential to find a proper solution… Supposing the widget title was Title [php] More Title: add_filter( ‘widget_title’, ‘pseudo_php_wpse_90360’, 10, 3 ); function pseudo_php_wpse_90360( $title, $instance, $id_base ) { if( FALSE === … Read more
@tf is almost there, I think. You can use JS on your widget’s admin form, as I’ve done it before (though not for validation). Within your widget’s constructor, add an action: add_action( “admin_print_scripts-widgets.php”, array( __CLASS__, ‘register_my_validation_script’ ) ); Then create the corresponding function inside your widget’s class: function register_my_validation_script() { wp_enqueue_script( ‘my-script-handle’, plugins_url( ‘/my-validation-script.js’, __FILE__ … Read more
Default widgets are not usually activated with the theme. Themes add default widgets in the sidebar template file. For example take a look at twenty ten sidebar.php file: <?php /** * The Sidebar containing the primary and secondary widget areas. * * @package WordPress * @subpackage Twenty_Ten * @since Twenty Ten 1.0 */ ?> <div … Read more
If you want to display a fallback sidebar, you can do the following. If you want to decide which widget gets displayed, then idk. Create 2 sidebars. Example: sidebar and fallback-sidebar. In your template you can use: if(is_active_sidebar( ‘sidebar’ )){ dynamic_sidebar( ‘sidebar’ ); } else { dynamic_sidebar( ‘fallback-sidebar’ ); } If you just trying to … Read more