• Resolved brynfld

    (@brynfld)


    I’ve tried scouring this forum, the documentation and google for an answer to this question but have either gotten to a point where I dont understand anything being described or have not found any answers at all.

    All I want to know is if it is possible to set default content for a post type created with this plugin. I am creating this site for users that are not experienced with wordpress so I am trying to make it as easy as possible for them to create posts with the content mostly filled out. This plugin makes it very easy to create the new post types and manage them, but I cant find any way fill out the content for that post with default values.

    I have seen many posts regarding this topic that usually end in “Look at Taxonomies” but I dont know how to use them in relation to the post types at all.

    If anyone has any tips for me, thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The answer was at top of Google on search for: default content worpress new custom post. Add to your functions.php

    add_filter( 'default_content', 'my_editor_content', 10, 2 );
    
    function my_editor_content( $content, $post ) {
    
        switch( $post->post_type ) {
            case 'sources':
                $content = 'your content';
            break;
            case 'stories':
                $content = 'your content';
            break;
            case 'pictures':
                $content = 'your content';
            break;
            default:
                $content = 'your default content';
            break;
        }
    
        return $content;
    }

    That code example has default content for 3 custom post types and the default for all new posts.

    Simply replace the case ‘sources’ with the Post Type Slug of your custom post e.g. case ‘my_custom_post_slug’ and update the default content… add/remove any un-needed post types.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Can confirm that the code above is working. This isn’t going to be an issue exclusive to CPTUI, for what it’s worth, but one that’s related to posts/cpts as a whole in WordPress.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Completely lost regarding default content for custom post types’ is closed to new replies.