Changing default ‘posts’ hierarchy parameter with register_post_type_args
-
Hi everyone!
I’m having trouble trying to update WordPress core ‘post’ registered arguments to improve a functionality in my website. Specifically, I want to be able to have a hierarchy between my posts so I can set parents and childs for posts. Creating a custom post type to create this won’t help me as all my content is based in posts.
By default, WordPress allows this only for Pages post type.
Recently, WordPress added a neat function to modify arguments from an already registered post type, called “register_post_type_args”. This should work both for default and custom post types. I have come accross this code and modified to add what I need: Change capability type of post type registered by plugin
The results are below. However, when I add this to my functions.php, somehow, I can’t get this to work. My website returns a “Parse error: syntax error, unexpected end of file”.
add_filter( 'register_post_type_args', 'allow_post_hierarchy' , 10, 2 ); function allow_post_hierarchy( $args, $post_type ){ // Do not filter any other post type if ( 'post' !== $post_type ) { // Give other post_types their original arguments return $args; } // Change the capability_type of the "custom-css-js" post_type $args = array( 'hierarchical' => 'true', ); // Give the custom-css-js post type it's arguments return $args; }Does anyone have any idea why this is happening? I appreciate your input. Thanks!
The topic ‘Changing default ‘posts’ hierarchy parameter with register_post_type_args’ is closed to new replies.