I’m trying to make my own wordpress plugin, but it don’t work well. At the moment my php code is very simple :
//THE_CONTENT
function bjr() {
echo "COUUCOUUUU";
}
add_action('the_content', 'bjr');
But when i load a page the echo “COUUCOUU” is displayed for 10ms before the page and then disapear. Here is the first milliseconds when i refresh my page :
The first milliseconds when i refresh my page
And then :
My page after loading
And also, i don’t know why but my echo is displayed two times like ou can see in the screenshot, even though I only have one echo
I tried to activate and desactivate my plugin, when desactivated, my wordpress work well, but when i activate it, my page display this error message “Updating failed. The response is not a valid JSON response.”. I thought it was only my plugin fault but when i tried the preinstalled plugin “Holly Dolly” i had the same problem.
I also tried to change my add_action, instead of add_action('the_content', 'bjr'); i wrote
add_action('admin_notices', 'bjr');and it worked :
Admin side
I use wordpress on local only, so i tried to delete and download again but nothing changed, i also used a lot chatGPT but he didn’t helped me, same for every forums i saw, looks like i’m the first one to have this problem.
I don’t know what is the problem, maybe the plugin is loaded faster than the page, maybe my wordpress read two times my php so he display it two times, idk, i hope someone could help me