<?php//FUNCION ENTRADAS RELACIONADAS POR TAXONOMIAS CON IMAGENES------------------------------------------
function related_posts_juanjo(){
global $post;
// get the custom post type's taxonomy terms
$custom_taxterms = wp_get_object_terms( $post->ID, 'genero', array('fields' => 'ids') );
// arguments
$args = array(
'post_type' => 'pelicula',
'post_status' => 'publish',
'posts_per_page' => 20, // you may edit this number
'orderby' => 'title',
'order' => '',
'tax_query' => array(
array(
'taxonomy' => 'genero',
'field' => 'id',
'terms' => $custom_taxterms
)
),
'post__not_in' => array ($post->ID),
);
$related_items = new WP_Query( $args );
// loop over query
if ($related_items->have_posts()) :
echo ' <div class="container-carousel">
<div class="row">
<div class="span12">
<div id="owl-demo" class="owl-carousel">';
while ( $related_items->have_posts() ) : $related_items->the_post();
?>
<div class="item">
<a target="related" href="<?php the_permalink(); ?>">
<?php $images = get_custom_field('image_head:to_image_src'); foreach ($images as $img){printf('<img id="iu"class="lazyOwl" data-src="%s"/ alt="Lazy Owl Image" align="center">', $img);}?>
</a>
<a target="related" href="<?php the_permalink(); ?>"><a target="related" id="tittle-panel" href="#" onclick="showFicha('<?php echo $post->ID;?>'); return false;" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</div>
<?php
endwhile;
echo '</div></div></div></div>';
endif;
// Reset Post Data
wp_reset_postdata();
}
?>
<?php
function mostrar_ficha() {
if ( ! is_numeric( $_POST['post_id']))
die("Wrong ID!");
$_POST['post_id'] = abs(intval($_POST['post_id']));
if ( ! $_POST['post_id'] )
die("Wrong ID!");
if(isset($_POST['post_id'])){
global $post;
$post = get_post($_POST['post_id']);
if ($post!=null){
setup_postdata($post);
//aca lo que quieras mostrar en la ficha
?>
<div id="sinop-head">
<h1><?php the_title(); ?></h1>
<?php if(function_exists('ec_stars_rating')){ec_stars_rating();}?><div class="date-top"><div class="year"><?php echo get_the_term_list( $post->ID, 'año'); ?></div><div class="age"><?php echo get_the_term_list( $post->ID, 'edad'); ?></div><?php print_custom_field('duracion'); ?></div>
<p class="sinops"><?php print_custom_field('sinopsis'); ?></p>
<span class="director"><?php echo get_the_term_list( $post->ID, 'director', '<i class="fa fa-ticket"></i> ', ', ', ''); ?></span>
<div id="mytool" class="mytool"><?php $images = get_custom_field('director_image:to_image_src'); foreach ($images as $img){printf('<img id="img-director" class="img-director" src="%s"/ align="center">', $img);}?></div>
<p class="actor">Reparto:<?php echo get_the_term_list( $post->ID, 'actor', ' ', ', ', ''); ?></p>
<p class="view-fm"><a href="#dialog" name="modal">Ver online</a> <a href="#dialog" name="modal">Descargar</a></p>
</div>
<div id="colum-img"></div><?php $images = get_custom_field('image_head:to_image_src'); foreach ($images as $img){printf('<img id="image-head" src="%s"/ align="center">', $img);}?>
<?php
}
}
die();
}
add_action('wp_ajax_mostrar_ficha', 'mostrar_ficha');
add_action('wp_ajax_nopriv_mostrar_ficha', 'mostrar_ficha');
?>