$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>php - Collapsible menu on post sidebar only expands and does not collapse|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

php - Collapsible menu on post sidebar only expands and does not collapse

matteradmin9PV0评论

I'm working to improve an existing wordpress theme that was built for my organization. I've run into a problem that I'm not familiar with: the archive menu displayed on each post will only expand, but cannot seem to collapse.

Here's a link to a live example: /

Scroll enough to get to the sidebar archive and click on a month and you'll find that the archives cannot be collapsed once expanded.

I've considered taking out this archive altogether, but that's still not the best option.

I'd appreciate any help on this that I can get. I can pull excerpts form the javascript file as needed.

Here's the code that runs the archive section of sidebar:

<div class="post-archives">
                <h3>Post Archives</h3>
                <?php
                    // The Query
                    query_posts( array(
                        'posts_per_page' => -1
                    ) );

                    $previous_month = false;
                    $post_date = false;
                    $semaphore = 0;

                    // The Loop
                    while ( have_posts() ) : the_post();

                            // Consecutive Runs
                            $previous_month = $post_date;
                            $post_date = get_the_date('F y');
                    ?>

                        <!-- Repeat -->
                        <?php if( $post_date != $previous_month && $semaphore == 1 ): $semaphore = 0; ?>
                                    </ul>
                                </div> <!-- /.collapse -->
                            </div> <!-- /.month -->
                        <?php endif; ?>
                        <?php if( $post_date != $previous_month && $semaphore == 0 ): $semaphore = 1;  ?>
                            <div class="month">
                                <a class="month-collapse-btn" role="button" data-toggle="collapse" href="#collapseExample<?= get_the_ID() ?>" aria-expanded="false" aria-controls="collapseExample"><?= get_the_date('F y') ?> <i class="fa fa-caret-down" aria-hidden="true"></i></a>

                                <div class="collapse" id="collapseExample<?= get_the_ID() ?>">
                                    <p class="post-title"><a href="<?= the_permalink(); ?>"><?php the_title(); ?></a></p>

                                    <?php foreach( get_the_category() as $category ): ?>
                                        <div class="category-name"><em>filed under <a href="<?= get_category_link( $category->cat_ID ); ?>"><?= $category->name ?></a></em></div>
                                    <?php endforeach; ?>

                                    <p class="post-excerpt"><?= excerpt(14); ?></p>

                                    <a href="<?= the_permalink(); ?>" class="read-more">CONTINUE READING</a>

                                    <div class="hr hr-gray"></div>

                                    <ul class="additional-posts">
                        <?php elseif( $post_date == $previous_month && $semaphore == 1 ): ?>
                                    <li><a href="<?= get_the_permalink(); ?>"><?= the_title(); ?></a></li>
                        <?php endif; ?>

                    <?php endwhile;

                    // Reset Query
                    wp_reset_query();
                ?>
                        </ul>
                    </div> <!-- /.collapse -->
                </div> <!-- /.month -->


                </div> <!-- /.post-archives -->
Post a comment

comment list (0)

  1. No comments so far