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
<?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
(@valchy)
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.
It is a WordPress function that you can use on theme template files.
Thread Starter
valchy
(@valchy)
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.
Do you want to insert a new post in the database or change post_content from an existing post?
Thread Starter
valchy
(@valchy)
I want to insert a new post with my own script outside wordpress that looks like the example above.
(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
(@valchy)
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?
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
To insert posts into the database: http://codex.wordpress.org/Function_Reference/wp_insert_post
Thread Starter
valchy
(@valchy)
Ok. I’ve solved it. Thank you very much.
No problem. Glad you have it solved.