githuber-md icon indicating copy to clipboard operation
githuber-md copied to clipboard

How can we retrieve the md content through rest api?

Open kuworking opened this issue 6 years ago • 2 comments

I'm trying to get the post content in markdown through the rest api, but I'm unable to do this

I've tried

$wp_post = get_page_by_title('post title', OBJECT, 'post');
$content = get_post_field('post_content_filtered', $wp_post->ID, 'edit'));

But I receive data like this

"<hr />
<h2>type: 'recipe'
date: 2019-12-20
...

Can I fetch the data as I can see it with the plugin editor?

kuworking avatar Jan 10 '20 14:01 kuworking

The post content needs to be decoded. I will take a look at REST API for this part. Please wait a few days. Thanks.

terrylinooo avatar Jan 10 '20 16:01 terrylinooo

*Thanks for replying so fast

Decoding as this

$wp_post = get_page_by_title('post title', OBJECT, 'post');
$content = html_entity_decode(get_post_field('post_content_filtered', $wp_post->ID, 'edit'), ENT_QUOTES | ENT_HTML5, 'UTF-8'));

seems to work

But looking at the comments at https://www.php.net/manual/en/function.html-entity-decode.php doesn't seem to be a standardized solution (?)

kuworking avatar Jan 10 '20 18:01 kuworking

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 2 days.

github-actions[bot] avatar Jun 27 '23 00:06 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Jun 30 '23 00:06 github-actions[bot]