I want assist with reloading some a part of page, actualy i wish to make reload some content (publish) on my small wordpress blog without reloading page.. simple customers can click refresh button and obtain new publish ...

Im make random.php file and im use in my page this file, so there's 6 random posts... Now i want reload this part on click without reloading all page, im try found solution around the google but cant find worthwhile tutorial or

My code: http://pastebin.com/nf6kzEZS

So that all this works very fine basically have Permalinks on Default (http://localhost/wordpress/?p=123)

However when i change Permalink script cant load random.php files, im try change extension to random.html and works but i have to load php..

Where could be problems.. im also put on localhost with no plug ins and same...

To begin with, you aren't including jQuery enjoy it should: using [cde]

Second, the issue you're encounter relates to relative pathways. Since you have enqueue_script in root (localhost/random.php), when you're into another page, localhost/publish/date/random.php is going to be... not found. Seem sensible? :)

Now, what i am doing is: in random.php i define a javascript variable (BEFORE including any custom script!), let us say sitepath :


Now, inside your script this can be done:

var SITE_PATH = '<?php echo home_url( '/' ) ?>';

Seem sensible?