Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1058397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:01:17+00:00 2026-05-16T18:01:17+00:00

I am trying to do something I have not seen before in wordpress. Basically,

  • 0

I am trying to do something I have not seen before in wordpress. Basically, when you arrive at the blog, a title, thumbnail and an excerpt is displayed. When a toggle button is pushed, the post should slide down to reveal the content. (<?php the_content(); ?>)

Here is my Jquery:

$(document).ready(function() {
          $('span.play a').click(function() {
               if ($('.toggleSection').is(":hidden"))
               {
                    $('.toggleSection').slideDown("slow");
               } else {
                    $('.toggleSection').slideUp("slow");
               }
               return false;
          });
     });

It works perfectly! However; because the toggle is placed within the wordpress loop, whenever the toggle button is pressed, all of the posts toggle open. For instance, If I have 10 posts on a page, and one toggle button is clicked, all of the toggles open. Here is my WP loop:

<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
                <div class="post" id="<?php the_ID(); ?>">
                    <div class="thumbnail">
                       <?php the_post_thumbnail( 'mainimg' ); ?>
                        <span class="play"><a href="#" onclick="jQuery('#comments').toggle();"><img src="<?php echo bloginfo('template_url'); ?>/images/play.png" width="30" height="36" alt="Play Video"></a></span>
                    </div>


                    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                    <h3>Posted in: <span><?php the_category(', ') ?>  </span>On: <span><?php the_time('l, F jS, Y') ?></span></h3>

                    <div class="entry">
                        <p><?php the_excerpt(); ?> </p>   
                    </div> <!-- entry -->

                    <div class="toggleSection">
                    <p><?php the_content(); ?> </p>
                    </div>



                </div> <!-- .post -->

              <?php endwhile; ?>

What you are seeing above, is that when span.play a is clicked, the togglesection slides down and reveals the content. When any single toggle is selected, all of the content appears. I would like it so each toggle is unique within the WP loop, and only reveals that entry’s content. Any ideas?

You can see a demo of my work so far here: http://vitaminjdesign.com/littlewindow/ Press the play button over the thumbnails to toggle!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:01:18+00:00Added an answer on May 16, 2026 at 6:01 pm

    You can slim down your current code and fix the issue with toggling all of them like this:

    $(function() {
      $('span.play a').click(function() {
         $(this).closest('.post').find('.toggleSection').slideToggle();
         return false;
      });
    });
    

    This goes up to the .post element using .closest() then does a .find() to get the .toggleSection only inside that .post. Then the toggle code can be condensed down to just a .slideToggle() call. The above centers around using the current element, $(this), then traversing to find the element(s) you’re after using the tree traversal functions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just came across something that I have not seen before and I thought
I want to have one callback function after actions are done, I'm trying something
I have something I am trying to achieve. I have a web application running
All i have something i have been trying to do for a while and
I'm trying to multithread something and i have my program set up such that
I am just trying to find out that does puppet have something similar to
I have searched a lot trying to find something for my purpose, however most
im trying to achieve something but i dont really know how I have set
I'm trying to create something that works like this but doesn't have any submenus.
I'm trying to build something on javascript that I can have an input that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.