On a movie information wordpress theme i am developing, i have an href with text "watch trailer" on each cover of all movies. This brings a modal window, and that is working already, but i want to bring the trailer of the movie onclick, without having to reload the page.
For testing purposes and to ask for help here, i've made a loop that will obtain the data necessary for this "info" href for only one movie.
(head.php has the ajax library in it)
Get.php:
<?php include 'head.php' ?>
<script>
function trailerProcess(){
$.ajax({
url: 'sendTrailer.php',
type: 'json',
beforeSend: function () {
$(".trailerPadding").html("Processing, wait please...");
},
success: function (response) {
$(".trailerPadding").html(response);
}
});
}
</script>
<?php
require('../../../wp-blog-header.php');
?>
<?php $args = array('tag'=> 'newMovies', 'posts_per_page' => 1,); ?>
<?php query_posts( $args ); ?><?php while ( have_posts() ) : the_post(); ?>
<a href="#modal<?php echo get_the_ID(); ?>" onClick="trailerProcess();" class="linkColorWhite">
<div class="botoninfo"><span>watch trailer</span></div>
</a>
<div id="modal<?php echo get_the_ID(); ?>" class="modalmask">
<a href="#close" title="Close" class="close">X</a>
<span class="TrailerTitle">Trailer: <?php echo the_title(); ?></span>
<div class="trailerPadding">
<?php // Trailer should be shown here // ?>
</div>
</div>
<?php endwhile; ?>
sendTrailer.php:
<?php require('../../../wp-blog-header.php'); ?>
<?php $values = get_post_custom_values("Trailer"); echo $values[0]; ?>
As outcome, i obtain a 404 error not found sendTrailer.php path on the ctrl+j chrome console. But if in sendTrailer.php i quit the require('../../../wp-blog-header.php');
i get a php "Fatal error: Call to undefined function get_post_custom_values..." displayed, so it finds the file, knowing that wp functions won't work.
But if i also quit the require function and write <?php echo "hello" ?>
the whole code works and the "hello" gets displayed.
So, my conclusion is that the require function is causing this 404 error not found... why?
¿How can i work out this?
Thanks.
EDIT: I have replaced the wp-blog-header.php with load.php, the wordpress data now works and i get no "processing...", but it still doesn't get nor echoes the custom value of $values in sendTrailer.php.