mercredi 12 septembre 2018

Display "accordion" when there are more than 6 posts in a category

On my project http://urlgone.com/931548/, I am displaying posts by category.

I have a "summary-section" and a "detail-section". The "detail-section" opens with a click on an "more-less-button" with a javascript-function.

The goal I don't achieve is, that i only want to display the button, if there are more than 6 blog-posts in the category.

Can anybody help me in programming an if/else statement or is there a much easier way?

                <div class="slide">
                    <div class="summary">
                    <?php $catquery = new WP_Query( 'cat=5&posts_per_page=6' ); ?>
                    <ul>
                        <?php while($catquery->have_posts()) : $catquery->the_post(); ?>
                            <article>
                                <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
                            </article>
                        <?php endwhile;
                        wp_reset_postdata();
                        ?>
                    </ul>
                </div>

                <div class="details">
                    <?php $catquery = new WP_Query( 'cat=5&posts_per_page=6&offset=6' ); ?>
                    <ul>
                        <?php while($catquery->have_posts()) : $catquery->the_post(); ?>
                            <article>
                                <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
                            </article>
                        <?php endwhile;
                        wp_reset_postdata();
                        ?>
                    </ul>
                </div><!-- end .details -->

                <a class="more-less-button-d" href="#" title="mehr Referenzen zur Ingenieurgeologie">mehr
                <span class='ti-arrow-down'></span>
                </a>

            </div>

Aucun commentaire:

Enregistrer un commentaire