• Hi guys,
    I have a strange issue. I am creating a tech blog but when I past code into a code block I get the dreaded json error. However when I change the code by putting a fullstop in the front it works. I have a video of the problem below.

    Does anyone have any ideas?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi, @josh31p

    It looks like the issue you’re experiencing is caused by WordPress trying to parse the code block as JSON, which is causing an error because the code you’re trying to include is not correctly formatted JSON.

    One solution you could try is to wrap the code block in a <pre> tag, which will tell WordPress not to try to parse the contents of the code block as JSON. You can do this by clicking the “Text” tab in the WordPress editor and adding the

     tags manually around the code block, like this:
    
    
    <pre>
    // your code goes here
    </pre>

    Alternatively, you could try using a plugin like "Disable JSON REST API" or "Classic Editor" to disable the JSON parsing functionality in WordPress. This should allow you to include code blocks in your posts without running into this issue.

    I hope this helps! Let me know if you have any other questions.
    Thank you.

    Thread Starter josh31p

    (@josh31p)

    Hi @sharif200,
    Thank you for your response, I tried the preformatted tag idea and the Disable json rest api but I still get the error. Do I need to do something after I install the plugin? I feel like I am doing something wrong?

    • This reply was modified 3 years, 2 months ago by josh31p.
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Problem Pasting code’ is closed to new replies.