$post->ID returning '1'
-
I’m having a very odd problem on something that was working days ago.
In my sidebar.php, the code looks at the post ID to determine which sidebar to load. This has been working for over a year.
However, only on some pages, it keeps going to the default sidebar, because when the code looks for the post ID, the value coming back is 1. On some pages, the post ID is coming back with the right value. On others, the value is 1.
Here’s the top of sidebar.php file:
global $post; print_r($post); //debugging global $forumids; echo 'Post id = ' . $post->ID //debugging
This displays the array for post with the ID of 1, then the ID itself of 1.
The content of the page loads on the site, but the sidebar.php file is not recognizing the post ID.
Any suggestions? I haven’t added any plugins or upgraded core in several months.
- The topic ‘$post->ID returning '1'’ is closed to new replies.