Help modifying functions.php
-
I’m trying to modify the functions.php file of a wordpress theme so that I can style my widgets easier. The theme I have has two sidebars.
The original code for my functions.php is as follows:
<?php
if ( function_exists(‘register_sidebar’) )
register_sidebars(2);
?>I have changed it to the code shown below. If works fine for the first sidebar but the second sidebar no longer shows up on my blog.
I don’t know how or where to change the below code so that it works with the second sidebar that I believe is called from the original code above as register_sidebars(2).
Would someone be able to assist me. Below is the new code I am using. Where should I be inserting register_sidebars(2)
Thank you
if ( function_exists(‘register_sidebar’) )
register_sidebar(array(
‘before_widget’ => ‘<div class=”widgy”><li id=”%1$s”
class=”widget %2$s”>’,
‘after_widget’ => ‘</div>’,
‘before_title’ => ‘<h2 class=”widgettitle”>’,
‘after_title’ => ‘</h2>’,
));
-
I jumped into WordPress today and have never looked at the file so I am sorry if this doesn’t help – but here we go
I noticed something similar to a lot of my Rails work. There’s a slight difference that may be affecting your sidebar(s). The original function reads “register_sidebars($var);” and yours now reads “register_sidebar(array(blah));”
The difference I see is that the word “sidebar” is singular in YOUR code. Try adding the “s” and see if that is a different function. register_sidebar() may just be a function for the only (or the first in your case) sidebar that is passed through it. register_sidebars() may have a foreach that runs them all.
It’s just a thought. Again – I’ve never messed with wordpress code in my life so I may be typing in vain.
Missing the
{and}for the if statement. Should beif ( function_exists('register_sidebar') ){ register_sidebar(array( 'before_widget' => '<div class="widgy"><li id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', )); }and yes, there is a difference between
register_sidebar()andregister_sidebars(). Spelling always matters.
The topic ‘Help modifying functions.php’ is closed to new replies.