BUG: Unable to distinguish a childless parent with new wpdb?
-
I have been working with an older version of the Sidebar code and have been trying to figure out how one determines if a page has no children.
One of the standard methods proposed has been the following line (on all widget based sidebars I have seen):
if ($wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = '$parent_id' AND post_status != 'attachment'")) { ?>
Where the assumption is: if a page has no children, there will be no pages with the parent’s ID in the
parent_ID
variable. This was because theparent_ID
attribute would only be set if there was a child page.BUT, with the newer versions of WP, two things seem to have changed.
- new pages seem to have the
parent_ID
set to themselves - when a page is revised, old versions of pages are stored in the database
Now, since the page itself seems to have
parent_ID
set to being it’s ownpage_ID
(orpost_ID
), this code does not work. Because now – this codeline never goes NULL.Any suggestions???
- new pages seem to have the
- The topic ‘BUG: Unable to distinguish a childless parent with new wpdb?’ is closed to new replies.