WordPress.org

Ready to get started?Download WordPress

Forums

Using predefined text in new posts (19 posts)

  1. dinobaby
    Member
    Posted 9 years ago #

    Hi everyone!!

    Most of my posts use a very similar structure:


    <img src="xxx" alt="xxx">
    Text
    From Text

    Si I was wondering if it is possible at all to set all new posts to include this code thus saving me a lot of time posting just "filling in the blanks"

    Thanx in advance

  2. moshu
    Member
    Posted 9 years ago #

    Put your code in backsticks (see the lines below the text area when you write your post here!) and then maybe we will understand what you are asking.

  3. dinobaby
    Member
    Posted 9 years ago #

    Hmm, lets see, here goes...(sorry for that)

    <a target="_blank" href="">
    <img src="http://dinobaby.net/wp-content/" alt="Bods">
    Text</a> From <a href="http://www.bodsforthemods.com " target="_blank">Bodsforthemods</a>

  4. moshu
    Member
    Posted 9 years ago #

    It is possible.
    Depending on what is set in your Options > Write, i.e simple or advanced controls, you can edit the edit-form.php or the edit-form-advanced in the wp-admin folder, by inserting your text in the textarea div. (Or you can do it in both files.) In the advanced form it would be around line 100.

  5. dinobaby
    Member
    Posted 9 years ago #

    What should I be looking for? i am really not good with php so I´m kinda lost here :S

  6. moshu
    Member
    Posted 9 years ago #

    It has nothing to do with php. Just do what wrote in my previous post.
    In a text editor open the files, e.g. wp-admin/edit-form-advanced.php and go the the line 100. It will look something like this:

    <div><textarea rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="5" id="content"><?php echo $content ?></textarea></div>

    then copy your text and insert it like this:

    <div><textarea rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="5" id="content"><?php echo $content ?><a target="_blank" href=""><img src="http://dinobaby.net/wp-content/" alt="Bods">
    Text</a> From <a href="http://www.bodsforthemods.com " target="_blank">Bodsforthemods</a>
    </textarea></div>

    Save the file. You can do the same thing in the edit-form.php if you are using the simple control for writing posts.

  7. dinobaby
    Member
    Posted 9 years ago #

    That did it Moshu!!! :)
    Thank you very much for your help and your patience, but hey! I´m a bit wiser just now!!

    Thans again

  8. moshu
    Member
    Posted 9 years ago #

    Glad it worked out :)
    Have fun!

  9. Skeary
    Member
    Posted 8 years ago #

    alright this is sort of related... *some* of my posts have very similar set-up.. is there a way to have different templates for different sorts of posts?

  10. Dreamers
    Member
    Posted 8 years ago #

    That is an excellent solution moshu.

    Is it somehow possible only put a predefined text into this textbox if it is still empty?

    Many thanks

  11. moshu
    Member
    Posted 8 years ago #

    I am not sure I understand your question.
    On the other hand, now that I am more familiar with WP I wouldn't recommend altering the core files... I'd rather go with a quicktag solution.
    See the tutorial about how to do this:
    http://www.tamba2.org.uk/wordpress/quicktags/

  12. Dreamers
    Member
    Posted 8 years ago #

    Your solution is the best way for my purposes, since there is no click necessary at all.

    The only problem with your solution is, that every time as the user edits the post the hardcoded text will be added again.

  13. moshu
    Member
    Posted 8 years ago #

    Oh, I see... I've never thought about that :)
    I guess there should be some coding trickery for that... but I am not a coder guy :(

  14. Dreamers
    Member
    Posted 8 years ago #

    oda lehet betenni egy if-et?

  15. moshu
    Member
    Posted 8 years ago #

    há' tudom én? - kódoláshoz annyit értek, mint ló az ábécéhez :)

  16. Dreamers
    Member
    Posted 8 years ago #

    O.k. Thanks anyway.

  17. Dreamers
    Member
    Posted 8 years ago #

    I edited the core as following and it seems to work fine:

    edit-form.advanced.php...

    <div><textarea rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="5" id="content"><?php echo $content ?>
    <?php
    if ($content=='')
    echo 'shit';
    ?>
    </textarea></div>

    Thanks Moshu for the starting idea!

  18. GrendelS
    Member
    Posted 8 years ago #

    ...but this solution is going to be overwritten by any upgrade. Is there another way to make it safe for upgrades (like the coming wp2)?

  19. misselaineous
    Member
    Posted 7 years ago #

    This actually still works.
    I just implemented it on my blog to include a snippet at the beginning of each post, as well as a signature at the bottom.

    However it does add the hardcoded text/coding again when the post is edited. Easily fixed, just a pain in the you-know-what.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.