Anthony
Anthony

Reputation: 131

Show more content on click title underneath title

I need to show the content of post in wordpress. Basically I need to show a div on click, but only the current post. I have the title and the excerpt looping on the page to show all post. I want to show the content of only the current title post clicked. Example below is what I currently have.

$(document).on('click', '.post-id', function() {
	$(myClass, ".post-content").show();
});
<div class="post-full">
<h2 class="post-id<?php //echo get_the_ID(); ?>"><?php the_title(); ?><div class="close">Close</div></h2>
<div class="post-excerpt"><h3><?php the_excerpt(); ?></h3></div>
<div class="post-content"><?php the_content(); ?></div>
</div>

Upvotes: 0

Views: 187

Answers (1)

user2594803
user2594803

Reputation:

If i understand correctly

$(document).on('click', '.post-id', function()
{
    var content = $(this).nextAll('.post-content');

    if (content.is(':visible'))
    {
        content.hide();
    }
    else
    {
        $('.post-content:visible').hide();

        content.show();
    }
});

Upvotes: 1

Related Questions