• Resolved richard12

    (@richard12)


    Hi, I am trying to populate the private pages with default content. I am using this but it doesnt seem to work. I assume the post type is “private-page”? Is there something I am missing.
    Any pointers would be helpful.
    Thanks in advance
    Richard

    add_filter( 'default_content', 'pu_default_editor_content' );
    
    function pu_default_editor_content( $content ) {
        global $post_type;
    
        switch( $post_type ) 
        {
            case 'private-page':
                $content = 'Default content for blog posts.';
            break;
    
            case 'page':
                $content = 'Default content for pages.';
            break;
    
          
        }
    
        return $content;
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter richard12

    (@richard12)

    Sorry found your support question with the answer.
    Thanks again

    Thread Starter richard12

    (@richard12)

    Hi, Sorry to get back again. I used the code I found in another thread. It worked by adding default content but doesnt then let you add content. It just returns to the default content and removes any edits. I wonder if there is a modification that will allow one to edit the default content in the post text editor? Thanks for any pointers.
    Richard

    add_filter('wp_insert_post_data', 'wppbc_client_portal_default_content', 10, 2);
    
    function wppbc_client_portal_default_content($data, $postarr) {
    
        if ($data['post_type'] == 'private-page') {
    
            $data['post_content'] = '<p>Welcome to your private page. </p><br>';
    
        }
    
        return $data;
    }
    

    Hi,

    Yes the custom code will add a default content but you will not be able to overwrite it. After you added the default content you will need to disable the custom code.

    I know that this is not the best solution. The dev team already has in their to do list the option to add a default content inside the Private Pages. This will be available in future updates.

    Unfortunately for the moment I don’t have another solution for this issue.

    Best regards,

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘default content’ is closed to new replies.