WordPress.org

Forums

Wrapping Posts with same category in a tag. (1 post)

  1. jeanhules
    Member
    Posted 1 year ago #

    Hello,

    I am trying to use Reveal.js (https://github.com/hakimel/reveal.js/) on WordPress with the Posts being the content per each slide.

    I have gotten the post to display properly on the slides, but I am having trouble finding a way to wrap posts that have the same category in a <section> tag.

    Basically, My current code looks something like this:

    <section class="section  chapter-1 ">
    </section>
    <section class="section  chapter-1 ">
    </section>
    <section class="section  chapter-1 ">
    </section>
    
    <section class="section  chapter-2 ">
    </section>
    <section class="section  chapter-2 ">
    </section>

    But I need it to look like this:

    <section id="category-1">
      <section class="section  chapter-1 ">
      </section>
      <section class="section  chapter-1 ">
      </section>
      <section class="section  chapter-1 ">
      </section>
    </section>
    
    <section id="category-2">
      <section class="section  chapter-2 ">
      </section>
      <section class="section  chapter-2 ">
      </section>
    </section>

    Here is my index.php code:

    <div class="reveal content-area">
      <div id="content" class="slides site-content" role="main">
        <?php if ( have_posts() ) : ?>
        <?php /* The loop */ ?>
        <?php while ( have_posts() ) : the_post(); ?>
        <?php get_template_part( 'content', get_post_format() ); ?>
        <?php endwhile; ?>
        <?php twentythirteen_paging_nav(); ?>
        <?php else : ?>
        <?php get_template_part( 'content', 'none' ); ?>
        <?php endif; ?>
      </div><!-- #content -->
    </div><!-- #primary -->

    ... and so on with more 'chapters' and more categories

    If you notice the second code example are grouped and wrapped in a section tag with an ID of the category name.

Topic Closed

This topic has been closed to new replies.

About this Topic