If you have troubles since the update to WordPress 4.5 please read this post before opening a new thread.
February 12, 2012 at 8:03 pm #9183
I’m using the Avisio theme and recently decided to create a sidebar widget that would display a stream of videos from Vimeo. I duplicated the sidebar_news.php and renamed it sidebar_vimeo.php. Then replaced all the class names and widget registration methods with custom names… then added the new widget in the functions.php
$autoload = array('sidebar_news','sidebar_vimeo');
When I went into WordPress to add the new widget to a page to test it out… I found something interesting. All the instances of Sidebar News has been replaced by the new Vimeo Sidebar widget. I double checked to make sure I had replaced ‘kriesi_sidebar_news_widget’ with ‘vimeo_widget’ everywhere in the theme, so I’m not sure what is going on.
I found a similar thread on the support forum about using the Sidebar News widget for Portfolio items… and it appears that I’ve done everything instructed in there. So my questions are… why did the “Avisio Sidebar News” widget get replaced with my “Vimeo Sidebar” widget? Why don’t they both show up?February 12, 2012 at 8:33 pm #63767
As with my last post… I ask the question… and then figure it out.
The problem I found is that there are a couple more parameters that have to be changed in the class constructor. The Sidebar News constructor looks like this:
$widget_ops = array('classname' => 'community_news', 'description' => 'A Sidebar widget to display posts in your sidebar' );
$this->WP_Widget( 'community_news', THEMENAME.' Sidebar News', $widget_ops );
To get any duplicated class to work some parameters need to be changed in the new class to be unique. Here is the new working Sidebar Vimeo class constructor:
$widget_ops = array('classname' => 'sidebar_vimeo', 'description' => 'A Sidebar widget to display Vimeo videos in your sidebar' );
$this->WP_Widget( 'sidebar_vimeo', 'Vimeo Sidebar', $widget_ops );
The only thing to watch out for… the classname needs to be all lowercase. (ex. sidebar_vimeo)
Hope this helps someone out.February 13, 2012 at 6:57 am #63768
The topic ‘Duplicate Sidebar News Widget’ is closed to new replies.