0

I am trying to fetch posts in bootstrap accordion like this

<div class="container">
  <div class="panel-group" id="accordion">
        <?php
            if ( have_posts() ) :
                // Start the Loop.
                while ( have_posts() ) :the_post ();?>
                <div class='col-md-12 col-xs-12'>
                </div>
                <div class="panel panel-default">
                <div class="panel-heading">
                <h4 class="panel-title">
                <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="false" class="collapsed"><?php echo the_title()?></a>
           </h4>
            </div>
            <div id="collapseOne" class="panel-collapse collapse" aria-expanded="false" style="height: 0px;">
            <div class="panel-body">
            <p><?php echo the_content()?></p>
            </div>
            </div>
            </div>
             <?php
              get_template_part( 'content', get_post_format() );
              endwhile;
              twentyfourteen_paging_nav();

            else :
                // If no content, include the "No posts found" template.
                get_template_part( 'content', 'none' );

            endif;
        ?>
                </div>

    <?php // get_sidebar( 'content' ); ?>
                </div>

My problem is that once post content is printed inside the accordion and once again outside the accordion. How can I prevent the duplication?

1
  • Please do not start your title with "WordPress". This makes no sense on our site. :)
    – fuxia
    Commented Oct 25, 2015 at 13:53

1 Answer 1

0

get_template_part( 'content', get_post_format() ); includes a template part in your theme where it echoes out the content again. Commenting it out should fix that.

<?php
// get_template_part( 'content', get_post_format() );
endwhile;
twentyfourteen_paging_nav();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.