dimanche 1 mars 2015

Query show/hide current post in archive page


I'm having lot of headache with that since a couple fo days . . .


I explain my situation: I'd like to show/hide the_content on click of the_title of a post in my archive page.


Righ now, it display . . .the_content of every post, I suppose i need more jquery skills for this - but can not manage to make it work . . .


So far, here is the loop i am using:



<?php get_header(); ?>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($){
$(".event-info").hide();
$(".event-title").click(function(){
$(this).parent().children(".event-info").toggle("slide", {direction: "up"}, 500);
})
});
</script>
<?php $mainID = $post->ID; ?>

<div class="content-wrap col-xs-12 col-sm-12 col-md-12 col-lg-12">

<main id="main" class="site-main" role="main">
<ul class="archive_ad">
<?php
global $wp_query;
$args = array_merge( $wp_query->query_vars, array( 'posts_per_page' => 50, 'category_name' => '' ) );
query_posts( $args );
while(have_posts()): the_post();
?>
<li>

<div class="single-featured-image">

<div class="event-title"></div>
<h2>
<a href="javascript:void(0)" onclick="$('.img_side').hide();$('.event-info').show();">
<?php the_title(); ?>
</a>
</h2>
<?php if ( has_post_thumbnail()) : the_post_thumbnail('full'); endif;
?>

<div class="second_image">
<?php echo MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'close-up', get_the_ID(), 'thumbnail');
?>
</div>
</div>
<div class="event-info"><h2><?php the_title(); ?> </h2> <?php the_content(); ?></div>

</li>
<?php
endwhile; wp_reset_query();
?>

</ul>

<div class="img_side">
<img src="http://mysite/man_ok.jpg" alt="">
</div>


</div>
</div>

<?php get_footer(); ?>


Ive try to add an array such:



<a href="javascript:void(0)" onclick="$('.img_side').hide();$('.event-info').show($post_ID);">


and many others . .but can not make it work:(


Would really love any helps in that :)


Thank you for your time





Aucun commentaire:

Enregistrer un commentaire