I'm trying to create a lightbox effect for a self-made WordPress Theme. But I'm trying to include a WordPress page in the body through jQuery.
For example, in my js file.
$('.button').Click(function(){
$(body).append('`<div><?php get_template_part('content','thing'); ?></div>`');
});
I've tryed that and then my php file doesn't reproduce the php bit.
Thanks.
try
$('.button').Click(function(){
$(body).append("<div><?php get_template_part('content','thing'); ?></div>");
});
Remember to use this jquery in a
php
file not inJS
file.
it might help you
You can call a ajax functions that returns your php result.
Like (Seems you're using jQuery):
$.get("templatepart.php", function(data) {
$(body).append("<div>"+ data +"</div>");
})
And in your php file ("templatepart.php"):
<?php
// after includes/requires/etc functions
get_template_part('content','thing');
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.