I have a
404.php template for my theme. I also have
WP_DEBUG in wp-config.php set to
Consider this 404 template:
get_header(); ?> <div id="content" style="full-width"> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <div class="post-content"> Whatever. </div> </div> </div> <?php get_footer(); ?>
I get the following error:
Notice: Trying to get property of non-object in .../path/post-template.php on line 30
Now I know the error is caused by the call to
the_ID() on line 4. And the easiest solution would be for me to just remove it in the template.
However, there are places in other template parts,
header.php for instance, that either calls the same function or uses
An example would be
$project_meta = get_post_meta($post->ID, 'show_project_meta', true);. This is shared and works fine in any other template, i.e where the page has a post/page ID. What can I do for the 404 page?
Is there a way to fix this? Thanks.