Support » Fixing WordPress » Live Preview creates Internal Server error

  • Resolved tstarmer

    (@tstarmer)


    I have some themes that I have created by modifying _s (underscores) themes and can’t get the live preview to function to work on my live site. When trying to view any of my modified themes generates an Internal Server Error.

    Live Preview works for my themes on my local development site and themes by others work on both local and live sites. I tried an unmodified _s theme and it works so it is obviously something about my theme and the live site, but not sure how to track down what function(s) are creating the problem.

    Any help to track down what is going wrong would be greatly appreciated

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator t-p

    (@t-p)

    Have you tried:
    – Flushing any caching plugins you might be running, as well as server and/or browser caches.
    – deactivating ALL (yes all) plugins temporarily to see if this resolves the problem (plugin functions can interfere). If this works, re-activate them individually (one-by-one) to find the problematic plugin(s).
    – If you can’t get into your admin dashboard, try resetting the plugins folder by FTP. Sometimes, an apparently inactive plugin can still cause problems. Also remember to deactivate any plugins in the mu-plugins folder (if you have created such folder). The easiest way is to rename that folder to mu-plugins-old.
    – switching to the unedited default Twenty Fifteen theme for a moment using the WP dashboard to rule out any theme-specific issue (theme functions can interfere like plugins). If you don’t have access to your admin area, use FTP or whatever file management application your host provides. Navigate to /wp-content/themes/ and switch to the default theme by renaming your current theme’s folder by adding “-old” to the end of the folder name. Alternately, you can remove other themes except the default theme. That will force your site to use it.

    Tara thanks for the quick reply

    No caching plugins installed and yes all plugins are deactivated

    I can access the admin and know how to purge the problematic theme. I have noticed the them does crash on install as well. which is strange because I installed a similar one on another site.

    As I said I am sure it is a problem with the theme and what I hoping was someone could point me in the right direction on how to troubleshoot the conflict.

    Moderator t-p

    (@t-p)

    If switching to the default Twenty Fifteen theme resolved the issue, that suggests your current theme conflicting with something.

    What is the name of that theme? where did you download it from?

    Solved: I’ll post what i did in case it helps someone else

    The issue was a conditional HTML 5 shiv I added to the theme.

    I found the error by enabling debugging in wp-config and then the error outputed the line of code in the functions file that was creating the problem.

    The issue was I was using an anonymous function which worked on my local server but did not on the hosting server. I changed the function to a named function and everything works as expected.

    Code before

    add_filter( 'script_loader_tag', function( $tag, $handle ) {
        	if ( $handle === 'html5shiv' ) {
            $tag = "<!--[if lt IE 9]>$tag<![endif]-->";
        }
        if ( $handle === 'respond' ) {
            $tag = "<!--[if lt IE 9]>$tag<![endif]-->";
        }
        return $tag;
    	}, 10, 2 );

    Code after:

    function ie_conditional_filter($tag, $handle){
        	if ( $handle === 'html5shiv' ) {
            $tag = "<!--[if lt IE 9]>$tag<![endif]-->";
        }
        if ( $handle === 'respond' ) {
            $tag = "<!--[if lt IE 9]>$tag<![endif]-->";
        }
        return $tag;
    	}
    
    add_filter('script_loader_tag', 'ie_conditional_filter',10 , 2);

    Moderator t-p

    (@t-p)

    Glad to know it 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Live Preview creates Internal Server error’ is closed to new replies.