custom post types - Publishing failed. The response is not a valid JSON response

admin2025-01-07  4

I am using wordpress 5.4.2. I get this error when trying to add a new post. I changed my permalink to

Post name sample

http://localhost/wordpress/sample-post/

How should i change my .htaccess

My current htaccess is

    # Any changes to the directives between these markers will be overwritten.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /wordpress/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /wordpress/index.php [L]
    </IfModule>
    
    # END WordPress

~
Please help me II am new to wordpress

Akismet Anti-Spam Classic Editor Hello Dolly Increase Maximum Upload File Size Jetpack by WordPress myStickymenu OptinMonster API UberMenu 3 - The Ultimate WordPress Mega Menu .These are my installed plugins

This is my custom css

    .site-info { 
        display: none; 
    }
    
    .entry-meta .byline, .entry-meta .cat-links { display: none; }
    
    .entry-meta .posted-on { display: none; }
    .entry-footer{
        display:none;
    }
    
    .postmetadata {display:none;}
    
    .entry-meta {display:none !important;}
        .home .entry-meta { display: none; }
        .entry-footer {display:none !important;}
        .home .entry-footer { display: none; }

Console error

    [DOM] Found 2 elements with non-unique id #_wpnonce: (More info: https:// goo.gl/9p2vKq) <input type=​"hidden" id=​"_wpnonce" name=​"_wpnonce" value=​"65e17e3128">​ <input type=​"hidden" id=​"_wpnonce" name=​"_wpnonce" value=​"2ba7a6de71">​
    /wordpress/wp-json/wp/v2/users/me?_locale=user:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    data.min.js?ver=e80048e7b309581a40e44b8bd8aaba41:2 Uncaught (in promise) Objectcode: "invalid_json"message: "The response is not a valid JSON response."__proto__: Object

I am using wordpress 5.4.2. I get this error when trying to add a new post. I changed my permalink to

Post name sample

http://localhost/wordpress/sample-post/

How should i change my .htaccess

My current htaccess is

    # Any changes to the directives between these markers will be overwritten.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /wordpress/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /wordpress/index.php [L]
    </IfModule>
    
    # END WordPress

~
Please help me II am new to wordpress

Akismet Anti-Spam Classic Editor Hello Dolly Increase Maximum Upload File Size Jetpack by WordPress.com myStickymenu OptinMonster API UberMenu 3 - The Ultimate WordPress Mega Menu .These are my installed plugins

This is my custom css

    .site-info { 
        display: none; 
    }
    
    .entry-meta .byline, .entry-meta .cat-links { display: none; }
    
    .entry-meta .posted-on { display: none; }
    .entry-footer{
        display:none;
    }
    
    .postmetadata {display:none;}
    
    .entry-meta {display:none !important;}
        .home .entry-meta { display: none; }
        .entry-footer {display:none !important;}
        .home .entry-footer { display: none; }

Console error

    [DOM] Found 2 elements with non-unique id #_wpnonce: (More info: https:// goo.gl/9p2vKq) <input type=​"hidden" id=​"_wpnonce" name=​"_wpnonce" value=​"65e17e3128">​ <input type=​"hidden" id=​"_wpnonce" name=​"_wpnonce" value=​"2ba7a6de71">​
    /wordpress/wp-json/wp/v2/users/me?_locale=user:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    data.min.js?ver=e80048e7b309581a40e44b8bd8aaba41:2 Uncaught (in promise) Objectcode: "invalid_json"message: "The response is not a valid JSON response."__proto__: Object
Share Improve this question edited Jul 30, 2020 at 14:10 Tom J Nowell 60.7k7 gold badges77 silver badges147 bronze badges asked Jul 30, 2020 at 12:17 Midhun RajMidhun Raj 1115 bronze badges 18
  • 1 You shouldn’t need to change your htaccess. Have you made any other changes recently. New plug-in? Theme? Custom code? – Jacob Peattie Commented Jul 30, 2020 at 12:27
  • no .I havent added any plugins i just changed the permalink to new post – Midhun Raj Commented Jul 30, 2020 at 12:29
  • can you please tell me how to change the .htaccess – Midhun Raj Commented Jul 30, 2020 at 12:29
  • 1 Deactivate all of your plugins. If the problem goes away (which it probably will) then re-activate each one of the plugins until you find the one that is causing the issue. If you get this problem with all Plugins deactivated, thats a lot more curious... – t2pe Commented Jul 30, 2020 at 13:34
  • 1 @somanraj I edited out the pastebin link and put the result in the question, don't link offsite, embed the info directly in the question. In the meantime, the error message makes it clear what the problem is, 2 HTML tags with the same id value. It also looks like you have JS that calls a REST API endpoint that doesn't exist, or, you haven't saved permalinks since the endpoint was added. Unfortunately your dev console isn't wide enough to display the full URL of those endpoints so I cannot tell which it is. Also turn off all plugins and turn them on 1 by 1 to identify the culprit – Tom J Nowell Commented Jul 30, 2020 at 14:12
 |  Show 13 more comments

2 Answers 2

Reset to default 0

There are a number of guides around on how to resolve this. Here is one example. In short, there's no one solution, this error can be caused by multiple issues that you all might have to address.

However, like for many others (here are a few), these suggestions have not fixed the problem for me when I, on multiple occasions, encountered this problem, on multiple Wordpress installs.

The few times that I had to do a deep dive into what was actually the underlying cause, each time I found that it was a specific link, inside a paragraph which, when removed, made the problem go away.

Just today, I encountered this problem on a five year old Wordpress post. The post predated Gutenberg, and was using the Classic Editor. Converting to the Block Editor, or not, made no difference.

After combing through the post, I found that removing one single link resolved the problem. The link in question:

https://www.oecd-ilibrary.org/docserver/eag-2017-en.pdf?expires=1523985351&id=id&accname=guest&checksum=5B06368AEE8D0E4FDC5531078FA481B1

Nothing really strange, as the link properly resolves. What I do notice, here, is that the link above resolves to a page, but not a pdf, as the link implies. On the page itself, the link that is provided to the document that is linked to is this:

https://read.oecd-ilibrary.org/education/education-at-a-glance-2017_eag-2017-en#page1

Replacing my offending link with the latter resolved the problem for me.

I've seen this before, a URL that seems fine, causing Wordpress to fail when trying to save a post. Perhaps this is your problem, too.

Update: I'm cleaning up old posts and found more links that resulted in posts failing to save. Several were links to PDFs, a few were Google Doc links, some were http, not https, and some were just plain links to newspaper websites.

I also found that having links set to open in new windows can result in this error, as does having anchors in the classic editor.

I bet you are on a localhost server, I had the same issue and fixed changing files permission. ALL wp-content files & folders, and ALL wp-includes folder & files must have full permissions.

If you are on localhost this is not a problem, you could simply give full permission to the entire WP installation

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736260037a634.html

最新回复(0)