Title: Write posts with ENTER press with code
Last modified: August 20, 2016

---

# Write posts with ENTER press with code

 *  Resolved [valchy](https://wordpress.org/support/users/valchy/)
 * (@valchy)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/write-posts-with-enter-press-with-code/)
 * Hi. I don’t know if I post where it should be, but I have an issue with writing
   code (php).
    When I write the post from the admin panel I use something like 
   this:
 * Post text:
 * Post name: a short description of the post
    (hit ENTER 2 times and it make a 
   blank line between my short description and the rest of the post) Rest of the
   post I’ve checked my sql post text and it appears with the right line space. 
   How can I do this using php outside the admin panel (with my own script)?
 * Thank you in advance.

Viewing 12 replies - 1 through 12 (of 12 total)

 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/write-posts-with-enter-press-with-code/#post-2229817)
 * With php you can use `/n` or `/r` in double quoted strings: [http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double](http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double)
 *     ```
       <?php
       $var = "Post name: /n/nRest of the post";
       // to echo this as two paragraphs <p></p> use apply filters
       echo apply_filters('the_content', $var);
       ?>
       ```
   
 * with html tags you can use: `<br />`
 *  Thread Starter [valchy](https://wordpress.org/support/users/valchy/)
 * (@valchy)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/write-posts-with-enter-press-with-code/#post-2229842)
 * Thank you for the answer. This “apply_filters()” is a stand-alone function or
   shhould I get it from wordpress? Because if I’m outside of admin panel I cannot
   use it.
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/write-posts-with-enter-press-with-code/#post-2229843)
 * It is a WordPress function that you can use on theme template files.
 *  Thread Starter [valchy](https://wordpress.org/support/users/valchy/)
 * (@valchy)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/write-posts-with-enter-press-with-code/#post-2229915)
 * I don’t know if I said everything right:
 * What I meant is:
    my post text looks like this:
 * > main body post
   >  **this is the blank line** rest of the body post.
 * In the edit.php from admin post I obtain this blank line by pressing ENTER. Inside
   mysql on the field wp-post the text looks exactly the same (I mean no /n or something
   like this).
    The text post looks like this:
 * > main body text
   > rest of the body post.
 * How can I do this? I mean to insert into mysql the text this way?
    Thank you 
   again.
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/write-posts-with-enter-press-with-code/#post-2229916)
 * Do you want to insert a new post in the database or change post_content from 
   an existing post?
 *  Thread Starter [valchy](https://wordpress.org/support/users/valchy/)
 * (@valchy)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/write-posts-with-enter-press-with-code/#post-2229918)
 * I want to insert a new post with my own script outside wordpress that looks like
   the example above.
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/write-posts-with-enter-press-with-code/#post-2229919)
 * (sql example)
 *     ```
       INSERT INTO mytable (myfield) VALUES ('hi this is some text
       and this is a newline.
   
       and another double newline');
       ```
   
 * With sql you can just insert the text with newlines in them.
 *  Thread Starter [valchy](https://wordpress.org/support/users/valchy/)
 * (@valchy)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/write-posts-with-enter-press-with-code/#post-2229926)
 * Ok. Thank you very much.
 *  Thread Starter [valchy](https://wordpress.org/support/users/valchy/)
 * (@valchy)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/write-posts-with-enter-press-with-code/#post-2229928)
 * Can this be done when using a variable instead of the exact text?
 * I mean:
 * `$sql = "INSERT INTO mytable (myfield) VALUES ('$article');`
 * How $article can be made?
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/write-posts-with-enter-press-with-code/#post-2229933)
 * try it with:
 *     ```
       $my_var ="this is text
   
       this is also text
   
       and here is more text";
       ```
   
 * Something tells me I do not really know what you want to do.
    To interact with
   the database: [http://codex.wordpress.org/Class_Reference/wpdb](http://codex.wordpress.org/Class_Reference/wpdb)
   To insert posts into the database: [http://codex.wordpress.org/Function_Reference/wp_insert_post](http://codex.wordpress.org/Function_Reference/wp_insert_post)
 *  Thread Starter [valchy](https://wordpress.org/support/users/valchy/)
 * (@valchy)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/write-posts-with-enter-press-with-code/#post-2229934)
 * Ok. I’ve solved it. Thank you very much.
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/write-posts-with-enter-press-with-code/#post-2229935)
 * No problem. Glad you have it solved.

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Write posts with ENTER press with code’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 12 replies
 * 2 participants
 * Last reply from: [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * Last activity: [14 years, 10 months ago](https://wordpress.org/support/topic/write-posts-with-enter-press-with-code/#post-2229935)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
