Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

The following code in my functions.php file causes me to get a whitescreen when working in the admin area, not sure what could be wrong with this code.

<?php
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
));
}
?>
share|improve this question
Please add debug information to your question to make answers possible. – toscho Dec 23 '12 at 22:27

closed as too localized by toscho Dec 23 '12 at 23:22

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

3 Answers

I tried this and it worked great:

function wpse_16722_widgets_init() {
    register_sidebar(array(
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
        'before_title' => '<h2 class="widgettitle">',
        'after_title' => '</h2>',
    ));
}
add_action( 'widgets_init', 'wpse_16722_widgets_init' );

If this not working try to enable WP_DEBUG in your wp-config.php

share|improve this answer

I had to get rid of a opening and closing php tag, i guess wordpress doesnt like it when you dont wrap all of your functions on one big php tag instead of separately wrapping them.

share|improve this answer

That code shouldn't break anything unless you've nested the PHP tags. In other words, you can't have one <?php inside another <?php. I am guessing that is what has happened. Most of your functions.php is PHP. You don't need to add those opening and closing PHP tags unless you actually need to enter or leave PHP.

This is OK.

<?php
function test_1() {
}

function test_2() {
}

This is OK.

This is OK, but contains unnecessary opening and closing tags. It isn't broken though.

<?php
function test_1() {
}
?>
<?php
function test_2() {
}
?>

This isn't.

<?php
function test_1() {
}

<?php
function test_2() {
}
?>

function test_3() {
}

That you have the latter is the only possibility I can see at the moment.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.