I installed a Wordpress distribution in a subfolder. Everything works fine: The rewrite rules a correct and so on.

only my own private plug-in doesn't. I call per ajax the plug-in function via the url: /wp-content/plugins/plug-in-name/save_contribution.php

The absolute path is: http://domain.com/subir/wp-content/....

I know that's not the proper way to do AJAX in WP but I can't change it right now. I will in future - I promise :-)

The interesting point is: When I call it, it loads: http://domain.com/wp-content/...

So it goes back to the root. And it finds it because I have a different distribution in my root with the same plugin - so it writes in the wrong database

Can someone help me one that?

And again, I will rewrite my plugin in future but now I have to solve that issue quite quick!


  • So, your problem is what? As you already pointed in the question, you need to send the Ajax request to the correct URL, which must include the WordPress installation directory .... not sure what your question is. Can you please explain again where do you need help?
    – cybmeta
    Feb 14 '16 at 9:24
  • My problem is, that I have two WP dists installed. One in the root, and one in a subfolder of the root. When I now load the ajax via the relative path wp-content/... it loads the wp-content folder in the root not in the subfolder
    – urban-a
    Feb 15 '16 at 18:33

Use plugin_dir_url to get the URL of your plugin's directory.

$ajax_url = plugin_dir_url( __FILE__ ) . 'save_contribution.php'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.