• I have made several themes in WP, and no my way around the program pretty well. I have not worked with widgets, however. How much work is involved in making a theme “widget ready”?

    Thanks,

    – dz

Viewing 15 replies - 16 through 30 (of 42 total)
  • Thread Starter dwzemens

    (@dwzemens)

    epicalex,

    With the exception of this tweak (removing the last right parentheses from your code so the functions.php code is as follows:

    <?php if (function_exists(‘register_sidebars’)) register_sidebars(2); ?>

    it works terrific. Thanks so much. I owe you one.

    -dz

    no problems

    aquacky AT gmail DOT com, https://www.paypal.com ….. ??

    im only messin’!

    just glad i could help, its better than revising Goethe.

    Thread Starter dwzemens

    (@dwzemens)

    OK, experts one and all, the widget plugin now causes this error whenever I try to login to the WordPress dashboard:

    Warning: Cannot modify header information – headers already sent by (output started at C:\Program Files\xampp\htdocs\_wp\wp-content\plugins\widgets\widgets.php:1189) in C:\Program Files\xampp\htdocs\_wp\wp-login.php on line 12

    and I cannot get into the admin dashboard to disable widgets—-

    Any ideas how to fix this problem?

    Thanks – dz

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Edit the widgets.php file and make sure that there are no blank lines at the bottom of the file. The last characters in the file should be ?>.

    Thread Starter dwzemens

    (@dwzemens)

    Otto, I owe you, too. That was it. My many thanks,

    -dz

    Thread Starter dwzemens

    (@dwzemens)

    Otto,

    I made the theme live on my web server. Worked perfect on my local testing server. Now on the web server, when I try to SAVE or otherwise exit from the WP dashboard, I get this error:

    Warning: Cannot modify header information – headers already sent by (output started at /home/dwzemens/public_html/allcity/wp-content/themes/dollar/functions.php:6) in /home/dwzemens/public_html/allcity/wp-includes/pluggable.php on line 275

    It appears as though whatever I was working on in the Admin panel was saved or corrected as appropriate, but the error generates nonetheless.

    -dz

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Edit your theme’s functions.php file. Make sure that it has absolutely no blank lines at the beginning or end, outside the <?php and ?> markers.

    Thread Starter dwzemens

    (@dwzemens)

    Thanks Otto42 — the correct answer, as ususal.

    While I have you experts looking at this post, can you point me in the right direction to modify the standard text widget? I want to remove the <h2> display from the widget if the title is left empty. I can stumble around the PHP code if I know where to look.

    Thanks ahead of time,

    – dz

    look for this section, its near the top

    function register_sidebar($args = array()) {
    	global $registered_sidebars;
    
    	if ( is_string($args) )
    		parse_str($args, $args);
    
    	$defaults = array(
    		'name' => sprintf(__('Sidebar %d', 'widgets'), count($registered_sidebars) + 1 ),
    		'before_widget' => '<li id="%1$s" class="widget %2$s">',
    		'after_widget' => "</li>\n",
    		'before_title' => '<h2 class="widgettitle">',
    		'after_title' => "</h2>\n",
    	);

    the end bit is what puts the h2 tags in, you could probably create a statement so that if the input was blank, it would remove them, or maybe give a different class, that you could style differently? this would change the h2 tag for every widget though, not just the text one.

    the text widget code is low down,

    function widget_text($args, $number = 1) {
    	extract($args);
    	$options = get_option('widget_text');
    	$title = $options[$number]['title'];
    	if ( empty($title) )
    		$title = '&nbsp;';
    	$text = $options[$number]['text'];
    ?>
    		<?php echo $before_widget; ?>
    			<?php $title ? print($before_title . $title . $after_title) : null; ?>
    			<div class="textwidget"><?php echo $text; ?></div>
    		<?php echo $after_widget; ?>

    maybe look at removing some of the calls for before and after title, this would just effect the text one, not all.

    all a bit of a guess really, never done it myself.
    hope it points you in the right direction

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    It looks like that’s what the text widget already does. Note this line:
    <?php $title ? print($before_title . $title . $after_title) : null; ?>

    That’s basically saying to only print before_title, title, and after_title when the title itself is non-null.

    If it doesn’t appear to work the way you want, try changing it to this:
    <?php !empty($title) ? print($before_title . $title . $after_title) : null; ?>

    That might fix the problem.

    thanks for helping out otto, i didnt know what to do, so i just put the code that i knew needed to be changed, so you’re right, that was what the text widget already did! ??

    @joni – I have sent you a couple of emails in response to yours. Did you get them?

    Thread Starter dwzemens

    (@dwzemens)

    Thanks epicalex — I am a bit confused. Leaving the title blank on the widget interface prints no title, obviously, but the empty H2 tag is still ouput with a non-breaking space character. I am trying to get the H2 or other style markup to not be written to the HTML.

    ive worked it out. What otto said was nearly right, but not quite ??

    either put an ! before the ($title)…
    <?php !($title) ? print($before_title . $title . $after_title) : null; ?>

    or //

    <?php //($title) ? print($before_title . $title . $after_title) : null; ?>

    the ! does the opposite of what the php says, and the // edits it out, like putting in a comment.
    so it has basically just stopped the output on the text section only.
    let us know
    ??

    and actually, ive realised that this was something i wanted to do a while back, and never worked out how, so ive helped myself out here too!!
    ??

Viewing 15 replies - 16 through 30 (of 42 total)
  • The topic ‘Widget Ready — How much work?’ is closed to new replies.