The 404.php
template file is used for 404
errors: i.e. no posts found.
Since there are no posts, there is no $post
object. With no $post
object, functions such as the_ID()
are not available, and will return the error you’re observing.
The fix: replace all instances of $post
-derived data with static data. e.g. replace this:
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
…with this:
<div id="post-0" <?php post_class(); ?>>
Related Posts:
- Getting a 404 error when clicking edit page
- Featured Images most often doesnt appear
- How to check if post meta key exists or not in wordpress database
- How to add category to: ‘wp-admin/post-new.php’?
- Connection lost. Saving has been disabled… (Updating Posts/Pages)
- How can I retrieve multiple get_post_meta values efficiently?
- Code to make a post sticky
- How to allow hidden custom fields to be added from wp-admin/post.php?
- Export WordPress Posts and Meta Information in CSV format
- Fatal error: Call to undefined function post_exists()
- Delete duplicated wp_postmeta record
- Will a large postmeta table slow a site down?
- Update all posts automatically when using post_meta
- How to batch update post content with custom post meta value
- Change slug with custom field
- Better post meta efficiency?
- Setting post meta data to random value during post status transition / on publish
- 404 error after publishing a post
- Edit meta data does’t work with custom sql
- Some posts returning 404 instead of displaying post
- Custom post type single (permalink) throws a 404 error
- Human Time Diff, change mins to minutes
- Change post format using custom field
- Unable to modify(update) posts – Page not found
- Does WP get all post_meta on POST page?
- Sanitizing `wp_editor();` Values for Database, Edit, and Display
- Exporting Data from WordPress into a flat table
- Adding Multiple Values to a Post Meta Key
- Sql syntax error
- Debugging WP routing
- Using radio button meta data from a custom meta box
- Fatal error post.php help :(
- ‘Invalid post type’ error when importing from one site to another
- What Is meta_id In wp_postmeta?
- Checking if a post with certain meta value exists
- How to permanently delete a post meta entry?
- Add custom field automatically (add_post_meta) with value based on number of words of article
- How to generate numbers indistinguishable for the IDs of the posts
- Modify WP_Post before processing
- Save re-arranged draggable post items to wordpress database
- White Blank Page when Updating and Publishing Page/Post
- I would like to give special promotion for the first 100 posts in my blog? Can anyone tell me how to do that?
- Change post_date to post_modified date on post template?
- Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
- How can I sort posts by the date and a custom meta field?
- is there a way to show the the post title after the image?
- Get Meta Key Value While Saving Post
- 404 on paginated blog pages
- Classic editor throws 403 error based on post content
- How to display content from the main blog on another from multisite network as it would be its own
- Force the “Choose from the most used tags” meta box section to always be expanded
- Meta value does not save for scheduled posts
- Custom Posts Query and meta_query Sort Order
- Encountering “Wrong nonce. Action prohibitied.” when trying to alter User Role and unable to Post via WP Admin
- why are images not full size?
- How to compare two posts including their meta fields on a scalable base?
- Why does my site often display 404 on subpages?
- Getting value from get_post_custom
- Blank page when saving edits on post
- Calling Different Custom Post Timestamps in a table
- Is it possible to paste a link without tags and make it directly a link in a post?
- custom post template file not shown, instead all the time 404.php
- One post on my website is going to a 404 page
- Cannot retrieve a custom RSS field from posts
- How do I locate the exact location where this error is occurring 404 page not found
- 404 error on default post type and default taxonomy fronted page
- Saving custom fields to a custom taxonomy
- How to automate featured posts number? [duplicate]
- What do these phpMyAdmin errors mean on my WordPress databaes?
- Problems with Page Not Found
- Customize rel=canonical tag for single blog post
- Change all author links in Blog roll
- How to I retrieve the ID from the Posts page?
- How to save meta checkbox WordPress
- How to calculate the average of a post meta value(Numeric) of a specific author
- Is there any way to tell when wp_postmeta has been updated?
- getting “Object of class WP_Post could not be converted to string” – when it is a string
- wpColorPicker – problem with implementation to post meta
- Change post author without using wp_update_post()
- if in category but only with post meta
- wp_query with ajax
- Update post meta within save_post action
- Display post number by category
- Updating post meta for checkbox
- Saving Post Data in Another Database
- Posts and Pages: 404 Page not found
- Custom permalink for each post
- How can I tell if a post has been published at least once?
- Is there a way getting post fields using `transition_post_status`
- Automatic blog page with custom design [closed]
- Add multiple meta keys to a post at once
- Show number of posts by logged in user
- How does WP decide how to display a page
- When sending a newsletter -not with wordpress- the server has 100% cpu [closed]
- Retrieve data from post meta meta_key having ‘_product_fq_image’ while having author_id and post type is PRODUCT
- Insert data from custom created PHP page into wp_postmeta table
- Adding a meta box to determine the sidebar [closed]
- The loop starting at a certain ID
- saving/reading custom field value does not work – no value gets POSTed
- Simple Custom Metabox Not Saving