Preloaded text in post? (7 posts)

  1. westis4me
    Posted 9 years ago #

    I am wanting to have some text loaded into the text area when someone writes a post. I have tried editing the edit-form-advanced.php and that worked, however, I need to be able to edit the post again and when it is edited it adds the same thing again. I thought about making it into a quicktag but with my coding skills I couldn't get it to work.

    this below is what I want preloaded:

    Any help would be appreciated.

  2. moshu
    Posted 9 years ago #

    Use http://wordpress.pastebin.ca
    for posting long code. Thank you!

  3. Doing it in edit-form-advanced does seem like the simplest way to go.

    You'll find this bit of code in there:
    <div><textarea <?php if ( user_can_richedit() ) echo 'title="true" '; ?>rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="2" id="content"><?php echo user_can_richedit() ? wp_richedit_pre($post->post_content) : $post->post_content; ?></textarea></div>

    If you eliminate the stuff we don't care about, you'll see that it really breaks down to this:
    ...<textarea name="content"> some php code to put post_content here</textarea>...

    That's how the editing works. For new posts, post_content is empty. For editing older posts, it contains the post_content.

    So you can do something like this just one line up:
    if (empty($post->post_content)) {
    $post->post_content = "stuff you want in the post by default";
    <div><textarea ... blah blah ...

    And that should work.

  4. westis4me
    Posted 9 years ago #

    That worked great. Thank you.

  5. hchan
    Posted 9 years ago #

    That worked perfectly for me too, until I upgraded to WordPress 2.1.

    Any ideas on how to incorporate this into the new edit-form-advanced?

    Line 146 shows:
    <fieldset id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>">
    <legend><?php _e('Post') ?></legend>

    <?php the_editor($post->post_content); ?>

  6. rbenson
    Posted 9 years ago #

    I use a modded version of a technorati tag adder for wordpress.com using greasmonkey for my self hosted blog. Maybe you can use the GM script to auto load the text?

  7. hchan
    Posted 9 years ago #

    My apologies, the hack works. Maybe I needed to refresh my cache?

    Anyhow added:
    <?php if (empty($post->post_content)) {$post->post_content = "Short summary of the resource. Edit this as needed.";}?>

    Above this existing line in edit-form-advanced.php

    <?php the_editor($post->post_content); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.