Remove All Widgets from Sidebar

You could add this function to your functions.php file. add_filter( ‘sidebars_widgets’, ‘disable_all_widgets’ ); function disable_all_widgets( $sidebars_widgets ) { $sidebars_widgets = array( false ); return $sidebars_widgets; } You could also use the WordPress conditional tags to disable widgets only on certain pages. For example; this would only disable widgets on the home page. add_filter( ‘sidebars_widgets’, ‘disable_all_widgets’ … Read more

Why are my widgets not saving when being added to a sidebar?

Its the camel-case in the widget ID. The following works: add_action( ‘widgets_init’, ‘ditto_register_sidebars’ ); function ditto_register_sidebars() { register_sidebar(array( ‘name’ => __( ‘Right Hand Sidebar’ ), ‘id’ => ‘right-bar’, ‘description’ => __( ‘Widgets in this area will be shown on the right-hand side.’ ) )); } Per the Codex: id – Sidebar id – Must be … Read more

Video Embed in Sidebar Widget with Links to Others in Category

I would create a Custom Post Type for Videos, and use in conjunction with some plugin like Simple Video Embed From there you can make a list of videos like so: <?php query_posts(‘post_type= videoss’,’showposts=20′); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class=”vidoes” > <?php echo p75GetVideo($post->ID, 400); ?> <h5><?php the_title(); ?></h5> … Read more

Adding a widget programmatically

Because your code is just like prototype, it doesn’t display anything. That’s why your are not seeing anything in dashboard. /** * Adds Foo_Widget widget. */ class Foo_Widget extends WP_Widget { /** * Register widget with WordPress. */ function __construct() { parent::__construct( ‘foo_widget’, // Base ID esc_html__( ‘Widget Title’, ‘text_domain’ ), // Name array( ‘description’ … Read more

Randomize widgets displayed in my sidebar [duplicate]

I couldn’t see that the answers in the possible duplicate link are using the sidebars_widgets filter, so let me add it here as another possibility: The following assumes you use dynamic_sidebar() function to display your sidebars/widgets or just anything that calls the wp_get_sidebars_widgets() function. Randomize widgets: This code snippet displays all the widgets in a … Read more

Get custom side bar on custom post archive page

get_sidebar($name) will load a template sidebar-{$name}.php. If sidebar-{$name}.php does not exist, then it will fallback to loading sidebar.php. to have your specific sidebar, you can create a file sidebar-bibliography_sidebar.php in your theme with this code : <?php if ( is_active_sidebar( ‘bibliography_sidebar’ ) ) { dynamic_sidebar( ‘bibliography_sidebar’ ); }

Getting the Next and Previous Posts Titles in the Sidebar?

The existing WordPress functions are only for displaying one previous or next post. I quickly wrote functions to display any number of posts. Paste the following in your theme functions.php file: function custom_get_adjacent_posts( $in_same_cat = false, $previous = true, $limit = 2 ) { global $post, $wpdb; $op = $previous ? ‘<‘ : ‘>’; if … Read more

Determining a Widget Instance and Sidebar Location?

The widget_display_callback hook takes 3 arguments as we can see in /wp-includes/widgets.php: (line 180, WP 3.4.2) $instance = apply_filters(‘widget_display_callback’, $instance, $this, $args); So, to make a complete hook, the code is: // Priority = 10 // Arguments = 3 add_filter(‘widget_display_callback’, ‘wpse_57546_widget_display_callback’, 10, 3); // Using “$this” as an argument produces errors, // as it is … Read more

How to add author details in the post sidebar?

global $authordata; This variable contains the current post’s author data. From an author data widget I have written: global $authordata; if ( ( is_singular() or is_author() ) and is_object( $authordata ) and isset ( $authordata->ID ) ) { return $authordata->ID; } To get the link to the author archive: get_author_posts_url( $authordata->ID ); Update Here is … Read more

dynamic_sidebar not rendering sidebar

You should add the name and id parameters to your register_sidebar() argument array: ‘name’=>’Sidebar Name’, ‘id’=>’sidebar-slug’, Like such: register_sidebar(array( ‘name’=>’Sidebar Name’, ‘id’=>’sidebar-slug’, ‘before_widget’ => ‘<section>’, ‘after_widget’ => ‘</section>’, ‘before_title’ => ‘<h3>’, ‘after_title’ => ‘</h3>’, )); Then call the id of the Sidebar in your dynamic_sidebar() call: if ( ! dynamic_sidebar( ‘sidebar-slug’ ) ) { } … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)