I have a video gallery, and all the titles are generated by php. They are coming from my Wordpress media library's attachment titles.
The lightbox for these videos, however, is customized in javascript. How can I put the php titles inside the iframe markup?
PHP - need to use $attachment_data['title']:
<?php
$the_query = new WP_Query(array( 'post_type' => 'attachment','category_name' => 'video'));
while ( $the_query->have_posts() ) : $the_query->the_post();?>
<?php $attachment_data = wp_prepare_attachment_for_js( $attachment->ID );
echo'<div class="title"><h2>'.$attachment_data['title'].'</h2></div>';?>
<?php endwhile; wp_reset_postdata();?>
Javascript:
$('.video').Lightbox({
type: 'iframe'
iframe: {
markup: '<div class="lightbox_container">'+
'<iframe class="iframe" frameborder="0" allowfullscreen></iframe>'+
'<div class="title"> PHP GOES HERE </div>'+
'</div>',
callbacks: {
markupParse: function(template, values, item) {
values.title = item.el.attr('title');
}
});