• I have two blogs, one of which I had a customized theme made for (call this A). I recently created my second blog (B) and wanted to copy the exact theme from A to B and then modify it.

    Easy, just copy over the theme folder, right? Wrong. Everything copies over fine, but if I copy over the functions.php page, anywhere I click in WordPress Admin, I get this error (modified a bit to make it easier to read):

    Fatal error: Cannot redeclare site_url() (previously declared in /wp-includes/link-template.php:788) in /wp-content/themes/dapit_hapon/functions.php on line 2

    My functions.php file looks like this:

    <?php
    function site_url() {
      $url = "https://www.mydomain.com/"; // ENTER URL WITH TRAILING SLASH (/)
      echo $url;
    }
    ?>
    <?php
    $url = "https://www.mydomain.com/"; // ENTER URL WITH TRAILING SLASH (/)
    if ( function_exists('register_sidebar') )
        register_sidebar(array(
            'before_widget' => '',
            'after_widget' => '<div class="line_hor"><img alt="" src="' . $url . 'images/spacer.gif" width="1" height="3" /></div>',
            'before_title' => '<span class="txt1">',
            'after_title' => '</span><br /><br />',
        ));
    ?>

    mydomain.com was thrown in there to protect the innocent! ??

    I’m not really sure why I can’t just copy this theme from one blog to the next. Can anyone lend some advice? Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • It seems to me as you can’t re-declare a preserved function in link-template.php already declare. so the problem got to be with function name site_url()

    Thread Starter tbanucci

    (@tbanucci)

    I think that’s the problem too, but it’s working fine on my other blog: https://www.lastcuthomes.com/news/

    If I don’t have “function name site_url()” then should I erase that line or how do I fix it?

    Thread Starter tbanucci

    (@tbanucci)

    I have located the problem, but I still don’t know how to fix it, maybe someone here does.

    My new blog is running on 2.6.2 while the other blog with the original theme is on 2.6.0. I tried yesterday upgrading my other blog yesterday and found that the functions.php file screwed the whole blog, making it unable to run (with a similar error code). Once I removed the functions.php file, the blog displayed, but without much of the CSS it should. What I did was restore from a backup back down to 2.6.0 and everything worked properly again.

    So what this means to me is that there were some code changes in WordPress that conflict with my functions.php file. Since I’m a programming newb, maybe someone else in here knows what code in that functions.php file is bad? Or do functions.php scripts not even work anymore? Should I code it’s functionality somewhere else into my site?

    Any help would be appreciated!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘functions.php mess’ is closed to new replies.