Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1114848
    flysocal
    Participant

    Uh oh..
    With my limited knowledge… I changed my functions.php to add some code.
    It immediately blew up my page.

    Is there a way to replace my child functions.php with the previous one?
    I’m unable to log into my admin page.

    Thanks!

    #1114872
    flysocal
    Participant

    OK,
    Crisis averted! Always learning…

    I had to go to my host and replace the file.

    In the future… how do I know if a modification to a php file will result in a blown up webpage?

    Thanks in advance!

    #1114873
    flysocal
    Participant

    Um…. not so fast….

    All of my sidebar widgets are gone! How do I find them again? They weren’t included in the functions.php that I edited so I have no idea where their info is stored.

    Any help is appreciated.

    #1114885
    flysocal
    Participant

    Having a conversation with myself.

    Fixed it.
    For some reason they were listed in inactive widgets under the dashboard. Just had to drag them back to the sidebar.

    Finally… crisis averted. Hours of work to fix one quick error.

    Would like to know how to avoid a php error that is fatal.

    #1114923
    Nico
    Moderator

    Hi There,

    Thanks for writing in.

    Happy to hear that you have already fix the error.

    To avoid fatal error, you need to test your code first on your local or dev site before you put it in your live site.

    Hope it helps.

    Let us know how it goes.

    Thanks.

    #1116096
    flysocal
    Participant

    Can you explain how to test it on a local site? My website currently shows “Under Construction”… and I’ve done all my testing and creation through wp-admin. I haven’t yet taken my site live.

    How do I test it locally?

    Thanks,

    #1116171
    flysocal
    Participant

    ARRGH!

    I just did it agein. Can someone tell me what I’m doing wrong? I’ll attach the functions.php file. The only thing I changed (added) was the last function called Dynamic copywrite date.

    Thanks.

    #1116175
    flysocal
    Participant

    This is the text added to the functions.php for my child theme.

    // Dynamic copywrite date
    //
    =============================================================================
    function smallenvelop_copyright() {
    global $wpdb;
    $copyright_dates = $wpdb->get_results(”
    SELECT
    YEAR(min(post_date_gmt)) AS firstdate,
    YEAR(max(post_date_gmt)) AS lastdate
    FROM
    $wpdb->posts
    WHERE
    post_status = ‘publish’
    “);
    $output = ”;
    if($copyright_dates) {
    $copyright = “© ” . $copyright_dates[0]->firstdate;
    if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) {
    $copyright .= ‘-‘ . $copyright_dates[0]->lastdate;
    }
    $output = $copyright;
    }
    return $output;
    }
    //
    =============================================================================

    #1116286
    Jade
    Moderator

    Hi there,

    Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:

    – Link to your site
    – WordPress Admin username / password
    – FTP credentials

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    #1116658
    flysocal
    Participant
    This reply has been marked as private.
    #1116659
    flysocal
    Participant

    I’ve reset my functions.php to a non-broken version.
    The text above is what I added… and what caused the theme to crash.

    Am I editing the functions.php wrong? I’ve edited other php files before but never had a crash like this one.

    Thanks,

    #1116820
    Rue Nel
    Moderator

    Hello There,

    I have checked your code and found invalid format and characters that may have created the issue. Please do update it and use this instead:

    // Dynamic copywrite date
    // =============================================================================
    function smallenvelop_copyright() {
      global $wpdb;
      $copyright_dates = $wpdb->get_results("
        SELECT
        YEAR(min(post_date_gmt)) AS firstdate,
        YEAR(max(post_date_gmt)) AS lastdate
        FROM
        $wpdb->posts
        WHERE
        post_status = 'publish'
      ");
      $output = '';
      if($copyright_dates) {
        $copyright = "© " . $copyright_dates[0]->firstdate;
        
        if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) {
          $copyright .= '-' . $copyright_dates[0]->lastdate;
        }
        $output = $copyright;
      }
      return $output;
    }
    // =============================================================================

    Please be very careful with the quotes. It should be noted that you need to have to proper single or double quotes. Invalid characters could throw in a fatal error. In most cases, to keep track of the error, you can enable the WP_DEBUG mode? You can do this by opening wp-config.php and adding
    define( 'WP_DEBUG' , true ); just above /* That's all, stop editing! Happy blogging. */ For example:

    define('WP_DEBUG', true);
    
    /* That's all, stop editing! Happy blogging. */

    When you revisit the page with the blank screen, you should have some error output describing the issue in more detail.

    Hope this helps.

  • <script> jQuery(function($){ $("#no-reply-1114848 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>