• 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:
    https://wordpress.pastebin.ca/208501

    Any help would be appreciated.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Use https://wordpress.pastebin.ca
    for posting long code. Thank you!

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    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:
    <?php
    if (empty($post->post_content)) {
    $post->post_content = "stuff you want in the post by default";
    }
    ?>
    <div><textarea ... blah blah ...

    And that should work.

    Thread Starter westis4me

    (@westis4me)

    That worked great. Thank you.

    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); ?>
    </fieldset>

    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?

    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); ?>

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Preloaded text in post?’ is closed to new replies.