Fixes "Trying to get property of non-object" error on 404 pages
`$post` is not set if you are on a 404 page, so we need to check if it is set before we call `$post->post_name`, etc. (note that you would have to have `WP_DEBUG` set to `true` in wp-config.php in order to see this issue)
This commit is contained in:
@@ -25,7 +25,12 @@
|
|||||||
<script defer src="<?php echo get_template_directory_uri(); ?>/js/script.js"></script>
|
<script defer src="<?php echo get_template_directory_uri(); ?>/js/script.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body <?php $page_slug = $post->post_name; body_class($page_slug); ?>>
|
<body <?php if (isset($post)) {
|
||||||
|
$page_slug = $post->post_name;
|
||||||
|
body_class($page_slug);
|
||||||
|
} else {
|
||||||
|
body_class();
|
||||||
|
}?>>
|
||||||
|
|
||||||
<?php roots_wrap_before(); ?>
|
<?php roots_wrap_before(); ?>
|
||||||
<div id="wrap" class="container" role="document">
|
<div id="wrap" class="container" role="document">
|
||||||
|
|||||||
Reference in New Issue
Block a user