Loading PHP file using JQuery in Wordpress
I want to load a PHP file in a DIV with JQuery using the code below:
jQuery(pid + " .entry-details
.details-wrapper").load("http://thesitename.com/wp-content/themes/twentytwelve/entry-details.php",
{'postid': theid});
I have already added the code below to my theme's function.php:
function my_init_slider()
{
wp_register_script( 'bpslider-script-js', get_template_directory_uri()
. '/js/bpslider.js',
array('jquery'), 1.0, true );
wp_enqueue_script( 'bpslider-script-js' );
}
add_action( 'wp_enqueue_scripts', 'my_init_slider' );
However, the Wordpress functions (such as get_header() and query
functions) in my PHP file are not recognised, thus resulting in error 500.
I've tried stripping all the code and only echo the ID that I passed, and
it works. Therefore, I'm sure that the wordpress functions cause the
error. I know that including wp-load.php is not a good practice, so I'm
avoiding that.
Can anyone give me solution to this?
No comments:
Post a Comment