Been running into a critical error with WordPress Theme

190 views Asked by At

With one of my own WordPress Themes, I would click on any links under the recent posts category and I would receive the "gray screen of death" with the following error:

There has been a critical error on your website.

Learn more about debugging in WordPress.

I did the disable plugins deal but that didn't work. If you click on Archives and Categories, those work without no problems. Long story short, I walked away from studying WordPress and Web Development in early 2019 due to working mainly 55+ hours a week. Back in early 2019, those recent posts links worked, but now in Oct 2020, they don't.

Here's a link to the theme (yes, the footer is off, I'm looking to fix it next): https://rthomas.xyz/TestAreaA/

Thanks for the help, hopefully I'm making sense here.

1

There are 1 answers

0
Robbee Thomas On

After further digging, there was something wrong with my single.php. I did the following to create a debug.log file in the wp-content folder, you can find it on the WordPress website:

Example debugging for wp-config

Next, the debug.log told me of an error on my single.php. It's the reason why the Archives and the Categories links worked but not the single posts.

My single.php had the following code:

    <?php get_header(); ?>
<div class="container"> 
            <div class="primary">

            <!-- Start the Loop. -->
                <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
                <hr>
                    <h2><?php the_title(); ?></h2>
                    <p class="date-author">Posted: <?php the_date(); ?> by <?php the_author(); ?></p>
                    <p><?php the_content(); ?></p>
                    
                    <?php endwhile; ?> 
                    
                    <?php else : ?>
                
                    <p><?php _e( 'Sorry, no posts matched your critera.' ); ?></p>
                    
                <?php 

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) :
                comments_template();
                endif; ?>
                <hr>

            </div><!--/.primary-->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

It said that the error was on the last line. After some editing, I reduced it to this:

    <?php get_header(); ?>
<div class="container"> 
            <div class="primary">
<!-- Start the Loop. -->
                
                   <h2><?php the_title(); ?></h2>


    <p class="date-author">Posted: <?php the_date(); ?> by <?php the_author(); ?></p>
                    <p><?php the_content(); ?></p>
                
                    
                <?php 

                // If comments are open or we have at least one comment, load up the comment template.
                if ( comments_open() || get_comments_number() ) :
                comments_template();
                endif; ?>
                <hr>


            </div><!--/.primary-->

<?php get_sidebar(); ?>
<?php get_footer(); ?>