• I have just updated WordPress after a long time.
    I’ve been using a plugin -My Default Post Content– that allowed me to define a default code showed when I started a post. but, with the new editor, it doesn’t work.

    to solve that, at theme functions they wrote me a code:

    // ===================generating default post content =======================
    
    add_filter( 'default_content', 'my_editor_content' );
    function my_editor_content( $content ) {
        $content = '<div><span class="bodytitle">Subtítulo</span></div>
    
    	IMAGEN
    	
    	<p><span class="credit">créditos</span></p>
    	
    	Cuerpo<!--more-->
    	_
    	
    	GALERÍA';
        return $content;
    }

    and using another plugin –Classic Editor– it works. but Classic Editor does not use the more recent editor blocks editor of wordpress.

    there what is shows by default is:

    Imagen ejemplo

    I should need something like that:

    instead of:
    <!– wp:gallery {«linkTo»:»none»} –>
    <figure class=»wp-block-gallery columns-0 is-cropped»><ul class=»blocks-gallery-grid»></figure>
    <!– /wp:gallery –>

    this:
    <div><span class=”bodytitle”>Subtítulo</span></div>
    IMAGEN
    <p><span class=”credit”>créditos</span></p>
    Cuerpo<!–more–>
    _
    GALERÍA

    is there a way to reach that?

    • This topic was modified 4 years, 6 months ago by anafasia.
    • This topic was modified 4 years, 6 months ago by anafasia.
    • This topic was modified 4 years, 6 months ago by anafasia.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    I’ve yet to find a PHP method of inserting default content like we did before. We may need to rely upon JavaScript or jQuery to insert default content into the appropriate editor element after the editor has loaded. There will likely be a small delay between the editor appearing and the default content appearing.

    Thread Starter anafasia

    (@anafasia)

    so I assume there’s no easy way to solve that, am I wrong?

    • This reply was modified 4 years, 6 months ago by anafasia.
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘editor default content’ is closed to new replies.