Can posts have parents?

Are posts supposed to have parents? If so, what would that mean for a post to have a parent?

Also, if there are some constraints to posts having parents, then where is that enforced? Not in the DB as I see it.

5

Out of the box, no, posts can’t have parents. They can be assigned to categories, which can be organised hierarchically. Pages, however, can have parents and you can build a menu structure out of them by using that feature.

As to where this is enforced: The parent of a post is stored in the column “post_parent” in “wp_posts”. It’s not really enforced as such, just the default UI doesn’t give you an option to set it and default WP coding doesn’t use that value for Posts. It wouldn’t be too difficult to create a custom post type to have posts with parents though.

Leave a Comment