'Wordpress: Making posts have hierarchy
Hoping someone here can help. I need a solution to allow standard posts to have parent or child posts, similar to how pages already behave. I have tried the solutions at wordpress: how to add hierarchy to posts but the accepted answer no longer works (as noted in one of the comments) and while the second answer works to a point it changes the label in the menu to pages and rather annoyingly resets the order of the posts in the dashboard menu. Someone has already commented about this and unfortunately as a new user I cannot add a comment myself.
It would be amazing if someone could post a solution as while learning PHP is on my to do list, it is not something I have time to do at present. I've tried using custom posts but it seemed to create more problems than it was worth - for example, the hierarchical posts need to show on the homepage but the code used by the current theme only shows standard posts and not custom posts. This appears to be hard coded.
I will be inserting the code using the my custom functions plugin.
This is the code currently used. I tried editing it manually but broke the site...
(taken from the above linked question)|
add_filter( 'register_post_type_args', 'add_hierarchy_support', 10, 2 );
function add_hierarchy_support( $args, $post_type ){
if ($post_type === 'post') { // <-- enter desired post type here
$args['hierarchical'] = true;
$args['supports'] = array_merge($args['supports'], array ('page-attributes') );
}
return $args;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
