J
Juanjo87
Gamma
Diseñador
¡Usuario con pocos negocios! ¡Utiliza siempre saldo de Forobeta!
<script>
$(document).ready(function() {
$('#div-btn1').click(function(){
$.ajax({
type: "POST",
url: "prueba.php",
success: function(a) {
$('#div-results').html(a);
}
});
});
});
</script>
<a id="div-btn1" style="cursor:pointer;">Ver el archivo que contiene hola</a>
<div id="div-results"></div>
<?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(); ?>"><div id="capa"><i class="fa fa-play"></i></br><a target="related"id="tittle-panel"href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</div>
<?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>
</div>
<?php
endwhile;
echo '</div></div></div></div>';
endif;
// Reset Post Data
wp_reset_postdata();
}
?>
<?php related_posts_juanjo(); ?>
<div class="item">
<a target="related" href="<?php the_permalink(); ?>"><div id="capa"><i class="fa fa-play"></i></br><a target="related"id="tittle-panel"href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</div>
<?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>
</div>
<div id="div-results"></div>
<html>
<head>
<title>Ajax Simple</title>
<script src="jquery-1.3.2.min.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
$("#enlaceajax").click(function(evento){
evento.preventDefault();
$("#destino").load("contenido-ajax.html");
});
})
</script>
</head>
<body>
<a href="#" id="enlaceajax">Haz clic!</a>
<br>
<div id="destino"></div>
</body>
</html>
function mostrar_ralacionados() {
f ( ! 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'])){
$custom_taxterms = wp_get_object_terms( $_POST['post_id'], 'genero', array('fields' => 'ids') );
if (empty($custom_taxterms))
die("No se encontraron relacionados. ");
$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['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(); ?>"><div id="capa"><i class="fa fa-play"></i></br><a target="related"id="tittle-panel"href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</div>
<?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>
</div>
<?php
endwhile;
echo '</div></div></div></div>';
endif;
die();
}
}
add_action('wp_ajax_show_related', 'mostrar_ralacionados');
add_action('wp_ajax_nopriv_show_related', 'mostrar_ralacionados');
function showRelated(id){
$("#destino-"+id).show().html("Loading...");
jQuery.post(
"/wp-admin/admin-ajax.php",
{
'action': 'show_related',
'post_id': id
},
function(response){
$("#destino-"+id).html(response);
});
}
<?php
echo '<a href="#" onclick="showRelated('.$post->ID.'); return false;" >Mostrar Relacionados</a>';
echo '<div id="destino-'.$post->ID.'"></div>';
?>
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
?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php
}
}
die();
}
add_action('wp_ajax_mostrar_ficha', 'mostrar_ficha');
add_action('wp_ajax_nopriv_mostrar_ficha', 'mostrar_ficha');
<script type="text/javascript">
function showFicha(id){
$("#destino").show().html("Loading...");
jQuery.post(
"/wp-admin/admin-ajax.php",
{
'action': 'mostrar_ficha',
'post_id': id
},
function(response){
$("#destino").html(response);
});
}
</script>
<a target="related" href="<?php the_permalink(); ?>"><div id="capa"><i class="fa fa-play"></i></br><a target="related" id="tittle-panel" href="#" onclick="showFicha('<?php echo $post->ID;?>'); return false;" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<a target="related" href="<?php the_permalink(); ?>"><div id="capa"><i class="fa fa-play"></i></br><a target="related"id="tittle-panel"href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<div id="destino"></div>
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
?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php
}
}
die();
}
add_action('wp_ajax_mostrar_ficha', 'mostrar_ficha');
add_action('wp_ajax_nopriv_mostrar_ficha', 'mostrar_ficha');
<a target="related" href="<?php the_permalink(); ?>"><div id="capa"><i class="fa fa-play"></i></br><a target="related"id="tittle-panel"href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<a target="related" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" onclick="showFicha('<?php echo $post->ID;?>'); return false;"><div id="capa"><i class="fa fa-play"></i></br><span id="tittle-panel"><?php the_title(); ?></span>
//aca lo que quieras mostrar en la ficha
<script type="text/javascript">
function showFicha(id){
$("#content_principal").show().html("Loading...");
jQuery.post(
"/wp-admin/admin-ajax.php",
{
'action': 'mostrar_ficha',
'post_id': id
},
function(response){
$("#content_principal").html(response);
});
}
</script>
<?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');
?>
Pues no se, pero yo hago eso con un plugin de wordpress. Me deja elegir entre abrir la foto en una ventana nueva, abrirla directamente donde estoy, sobreimpresionada sobre el fondo. O abrirla en la misma ventana donde estoy, se quita la que tenga para cargar la foto.
No se si me he explicado.
Utilizamos cookies y tecnologías similares para los siguientes fines:
¿Aceptas las cookies y estas tecnologías?
Utilizamos cookies y tecnologías similares para los siguientes fines:
¿Aceptas las cookies y estas tecnologías?