Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This probably isn't the smartest way to go about it, but I'm very close to launch and the client wanted a news widget displayed two ways. Our theme's news widget displays a settable number of news entry titles. So, I created another widget that would display the news entries, with the only difference being that it prints their excerpts. When I duplicated the widget, I changed its registry name, loaded it through functions, and changed the widget output slightly. So I have two widget files called

widget-news.php
widget-news-excerpts.php

Their respective code begins like this:

From widget-news:

function gg_News_Widget() {

    /* Widget name and description */
    $widget_opts = array (
        'classname' => 'gg_news_widget', 
        'description' => __('Display your latest News Entries.', 'gxg_textdomain')
    );  

    $this->WP_Widget('gg-news-widget', __('SOUNDBOARD - News', 'gxg_textdomain'), $widget_opts);

}

From widget-news-excerpts:

function gg_News_Excerpt_Widget() {

    /* Widget name and description */
    $widget_opts = array (
    'classname' => 'gg_News_Excerpt_Widget', 
    'description' => __('Display EXCERPTS (and not titles) of your latest News Entries.', 'gxg_textdomain')
    );  

    $this->WP_Widget('gg_News_Excerpt_Widget', __('SOUNDBOARD - News Excerpts', 'gxg_textdomain'), $widget_opts);

}

I think I've been diligent about changing the name of the function throughout the new widget, except that when I update or add any sort of entry in the Dashboard, I now get:

Warning: Cannot modify header information - headers already sent by (output started at /home/safespac/public_html/kim.safespac.es/wp-content/themes/kimberley/includes/widgets/widget-news-excerpts.php:148) in /home/safespac/public_html/kim.safespac.es/wp-includes/pluggable.php on line 876

Any ideas about where to begin? I'm thinking of just figuring out how to add an checkbox option in the original widget that changes the display.

Thanks for any and all assistance or even pointing in the direction of a solution. I'm using WP 3.5.1.

share|improve this question
1  
The checkbox route would obviously be the better practice solution. That said, your error message tells you exactly where to begin: line 148 of widget-news-excerpts.php. Try looking there - or/and showing that code here (with line 148 indicated). –  vancoder Apr 27 '13 at 3:40
    
It would help if you would post the complete widgets. –  s_ha_dum Apr 27 '13 at 3:57
    
I came up with a detect page / CSS sort of solution for now. I'm leaning towards thinking it's a better use of everyone's time if I actually study how to add options to existing widgets, rather than copy-pasting code. But I will look at line 148 and go from there. Thanks for both of your answers! –  Rob Butz Apr 27 '13 at 5:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.