Home Forums ACF PRO Sidebar stays open when custom post page is opened


Sidebar stays open when custom post page is opened

  • I made a Bootstrap 5 sidebar that shows field choices as menu items and under field choices dropdown there are custom post pages who fit the current field choices.

    Now I want to make that specific dropdown menu stays open when user press on custom post page who are under the specific dropdown. To open menu I need to add show class, but how can I determine if user chose specific custom post page and how to make if statement in my sidebar to show dropdown opened when clicked on custom post page.

    My code:

    <?php $field = get_field_object('field_635a79a3e0657'); ?>
    <div class="col-md-3">
        <div class="flex-shrink-0 p-3 bg-white" style="width: 280px;">
            <a href="/" class="d-flex align-items-center pb-3 mb-3 link-dark text-decoration-none border-bottom">
                <svg class="bi me-2" width="30" height="24">
                    <use xlink:href="#bootstrap"></use>
                <span class="fs-5 fw-semibold">Rokasgrāmata</span>
            <ul class="list-unstyled ps-0">
                <?php foreach ($field['choices'] as $value => $label) : ?>
                    <li class="mb-1">
                    <button class="btn btn-toggle align-items-center rounded collapsed" data-bs-toggle="collapse" data-bs-target="#<?php echo $value; ?>-collapse" aria-expanded="false">
                            <?php echo $label; ?>
                        <div class="collapse <?php if(1){ echo $rokasgramate_id;}?>" id="<?php echo $value; ?>-collapse" style="">
                            <?php while ($objects->have_posts()) : $objects->the_post(); ?>
                                <?php if (get_field('kategorijas') == $value) { ?>
                                    <ul class="btn-toggle-nav list-unstyled fw-normal pb-1 small">
                                        <li><a href="<?php the_permalink(); ?>" class="link-dark rounded"><?php the_title()  ?></a></li>
                                <?php } ?>
                            <?php endwhile; ?>
                <?php endforeach; ?>
  • Can this post be deleted ?

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.