How to activate WordPress widgets but not display?
It sounds like you have a widget that you want to display on every page but the front page? If so, the Widget Logic plugin will do what you’re after. You should be able to use the logic !is_home().
It sounds like you have a widget that you want to display on every page but the front page? If so, the Widget Logic plugin will do what you’re after. You should be able to use the logic !is_home().
you can use wp_list_categories() to output an unordered list: <?php wp_list_categories( array(‘taxonomy’ => ‘product_tag’) ); ?>
I’d personally suggest an enqueue, it’s preferable where possible to make use of caching and script compression. Firstly, the enqueue. add_action( ‘admin_enqueue_scripts’, ‘add_sidebar_ids_to_widget_admin’ ); function add_sidebar_ids_to_widget_admin( $current_page_hook ) { if( ‘widgets.php’ != $current_page_hook ) return; wp_enqueue_script( ‘widget-admin-jquery’, get_stylesheet_directory_uri() . ‘/widget-admin-jquery.js’, array( ‘jquery’ ), ‘1.0’, true ); } I placed the code in a child theme’s … Read more
It sounds like a problem with that particular widget or if not that then your theme. Try again with a default theme and one of the wp widgets. Works fine with those.
function andrew_unregister_widgets() { unregister_widget( ‘WP_Widget_Archives’ ); unregister_widget( ‘WP_Widget_Calendar’ ); unregister_widget( ‘WP_Widget_Categories’ ); unregister_widget( ‘WP_Widget_Links’ ); unregister_widget( ‘WP_Widget_Meta’ ); unregister_widget( ‘WP_Widget_Pages’ ); unregister_widget( ‘WP_Widget_Recent_Comments’ ); unregister_widget( ‘WP_Widget_Recent_Posts’ ); unregister_widget( ‘WP_Widget_RSS’ ); unregister_widget( ‘WP_Widget_Search’ ); unregister_widget( ‘WP_Widget_Tag_Cloud’ ); unregister_widget( ‘WP_Widget_Text’ ); } add_action( ‘widgets_init’, ‘andrew_unregister_widgets()’ ); This unregisters all in-built wordpress widgets. Which ones of those are … Read more
I’ve had similar issues in the past with custom sidebars. It was caused by the improper use of the <ul> and <li> tags. I was adding them in the sidebar.php file and not inside the function. Now I use this code and with 6 active widgets I have no errors. Take a look at the … Read more
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
@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