This question seem to be unanswered. I find myself stuck on it. Here it goes
I’ve a problem with WP API to insert a post with HTML Tags.
I’m using the method: wp_insert_post() and the content is like this:
$content = "<p> <img src="img-link"> </p> <p> Hi, this is an example of the content.</p> <a class="dl" href="link-address"> Link Name</a>";
The result I want when I publish the post is:
A formatted post applying the html where necessary.
But the result I have when I publish the post is:
<p> <img src="img-link"> </p> <p> Hi, this is an example of the content.</p> <a class="dl" href="link-address"> Link Name</a>
When I go to the WP Editor to edit the same POST Directly, The Visual Editor looks well formatted as expected
And The then I navigate to Text Editor as see this well formatted too:
<p> <img src="img-link"> </p> <p> Hi, this is an example of the content.</p> <a class="dl" href="link-address"> Link Name</a>
It’s quite obvious that this is what I actually want. But When I do this post from my php file as stated earlier, I get this published:
<p> <img src="img-link"> </p> <p> Hi, this is an example of the content.</p> <a class="dl" href="link-address"> Link Name</a>
MY CODE
I HAVE TRIED
html_entity_decode($content);
And
Before Inserting to DB and
After The insert
My script only have the wp-load.php
loaded.
here is what I get with my real code… it seem it is inside <pre><code> $content </code></pre>
for some reason… I really need help with it:
UPDATE: I checked my database and the post includes this line <pre><code>
then the post itself </code></pre>
And I’m thinking if there’s a way to get rid of those It might work pretty well.
- Hiện tại chúng tôi có hơn 25 nghìn bài văn mẫu các thể loại.
- Kho tài liệu, đề thi học sinh giỏi các lớp vô cùng phong phú.
- Mỗi ngày cập nhật hơn 100 đề thi chất lượng từ các website bán tài liệu lớn.
Tải đề thi VIP với giá siêu rẻ tại Vip.Dethihsg247.Com