WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Default post layout

[Resolved] Default post layout

  • I was wondering if it possible to define a default layout of a post. Because I always blog with a certain post-layout, I would like to save me some time by typing everything again… so it would be very interesting if in the wp-admin panel, the layout is allready “pasted” in my new post text field.

    Is this possible? And if so, how? Which .php file do I have to edit and in what section exactly?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Yes you can define default content.

    <?php
    function my_default_content($content) {
    	$content = 'Your default content';
    	// $content = '<p class="example">Hello world!</p>';
    	return $content;
    }
    add_filter( 'default_content', 'my_default_content' );
    ?>

    You can do the same for the title and the excerpt to, same as above just replacing default_content for default_title or default_excerpt.

    and where do I have to edit this?

    functions usually reside in functions.php in your theme

    In plugin form..

    1. Create a new file, call it anything you like, but give the file a .php extension (aka a php file).
    2. Copy the code below into that file.

    <?php
    /*
    Plugin Name: My Default Content
    */
    function my_default_content($content) {
    	$content = 'Your default content'
    	// $content = '<p class="example">Hello world!</p>'
    	return $content;
    }
    add_filter( 'default_content', 'my_default_content' );

    3. Save the file.
    4. Upload to the plugins folder.
    5. Activate the plugin like you would any other.

    If you want to make any changes, just edit the file you’ve placed on the server (or use the builtin plugin editor if you prefer). I’ve obviously provided example HTML above, but if you need some help putting something specific into the code feel free to ask.

    thank you so much! this really helped me out!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] Default post layout’ is closed to new replies.
Skip to toolbar