• Resolved kadecooper

    (@kadecooper)


    I was able to get the content from our knowledgebase plugin to output content but is there a way to format it and/or remove the markup around the data?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Hi @kadecooper,

    What markup are you referring to? Can you send me an example?

    Thank you,
    Kevin.

    Thread Starter kadecooper

    (@kadecooper)

    Here is the output of our knowledge base
    https://www.omnidek.com/wp-json/wp/v2/epkb_post_type_1

    But it probably should be in a format similar to this

    View post on imgur.com

    thanks for the prompt response
    Kade

    • This reply was modified 5 years, 12 months ago by kadecooper.
    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    The format is JSON. I’m using a Chrome extension that formats JSON results and here is a sample of what I see when I go to the link you sent: https://imgur.com/a/yMw0Pqq.

    If you json_decode() this result in PHP or use JSON.parse() in your JavaScript, it should return a proper object.

    Thread Starter kadecooper

    (@kadecooper)

    Thank you!!!! I’ll send this information on to the team.

    Thread Starter kadecooper

    (@kadecooper)

    After thought, so this outputs inline css and html, is there a way to only pull the content?

    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    What you’re looking at in the screenshot is the value of the post_content field from the database. There’s HTML and CSS (in the screenshot) because there is HTML and CSS in the post’s post_content field in the DB.

    If you want to get rid of this, you have a few approaches. One would be to store the pure content in a meta field (this would be a bit tedious – you would need your content in two separate places and that’s never a good idea). Another approach could be to strip the tags using functions like wp_kses() and preg_replace(). There are a lot of resources online (especially regular expressions) showing how to strip tags while preserving content.

    Cheers,
    Kevin.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘JSON format’ is closed to new replies.