3
I have a posts page that shows the title of the post and I want to click on the title to open a DIV with the post itself.
I have no problem with the Javascript required for this. My problem is that all news is being shown, rather than just the one associated with the clicked title.
I believe my problem is in the loop, but I couldn’t fix it.
This is my current code:
<!-- laço -->
<?php query_posts('posts_per_page=2&cat=36');?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<figure class="effect-goliath">
<img src="<?php echo wp_get_attachment_url(get_post_thumbnail_id()); ?>" alt="<?php the_title(); ?>"/>
<figcaption>
<h2><?php the_title(); ?></h2>
<p><?php wp_limit_post(39,'...',true);?>...</p>
<!-- <a href="<?php the_permalink() ?>">Veja mais</a> -->
</figcaption>
</figure>
<div class="post-single">
<span class="close">Fechar</span>
<h2><?php the_title(); ?></h2>
<p><?php the_content(); ?></p>
<span class="close">Fechar</span>
</div>
<?php endwhile?>
<?php else: ?>
<h2>Nada Encontrado</h2>
<p>Erro 404</p>
<p>Lamentamos mas não foram encontrados artigos.</p>
<?php endif; ?>
<?php wp_reset_query(); ?>
<!-- fim laço -->
The div post-single is the one that will appear when you click on the title.