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.
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.
You must be logged in to post a comment.
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.
Wp has built in “Pages” (hierarchical, parents allowed) and “Posts” (non-hierarchical). There are also other post types, but let’s leave that away.
If the Q results in:
Then the answer is Yes,⦠you can have “posts” that are hierarchical. But as they are not built in, you’ll have to register your own Custom Post Type – see Arguments » hierarchical.
Such “Posts” (or articles, whatever, â¦) will then – in case they have a parent post – have set the parent ID inside their object. So in a loop you could do the following:
From a search engine perspective, two of these answers combined will help Google to track the hierarchy of your posts, as well as users of course.
Add a page and use it to host your posts.
“The best way to set a parent page through all of your posts is through the (Appearance -> Customize) menu. You can set a static page for your home page or posts page. When you set a static post page, that page will be the parent for every individual blog post.”
Change the permalink structure to /blog/%postname% as mentioned above.
“Suppose you want to append blog before post in url than make sure that your blog page’s slug name is blog .
Then go to WP-admin-panel > settings > permalink and choose the last option “custom structure” and add following in it:
/blog/%postname%/
and save changes. It will be only applied to your blog page, other page will not display blog as parent.”
This way, Google sees the hierarchy in sitemaps as domain.com/page/post (in that order) and will also find the content in the same place. As will users. Job done.
Suppose you want to append blog before post in url than make sure that your blog page’s slug name is blog .
Then go to WP-admin-panel > settings > permalink and choose the last option “custom structure” and add following in it:
and save changes.
It will be only applied to your blog page, other page will not display blog as parent.
I know this is an old post. However none of these answers are correct, and I wanted to post the solution I used to solve this problem. The best way to set a parent page through all of your posts is through the (Appearance -> Customize) menu. You can set a static page for your home page or posts page. When you set a static post page, that page will be the parent for every individual blog post.