0

I'm trying to organize my posts side by side but they keep being displayed vertically.

This is my code:

<div class="row agenda-box justify-content-start padding minheight-40">
    <div class="col-md-6 padding-top padding-bottom">
        <h5 class="main-text section-title">próximos eventos</h5>
        <?php
        $agendaHome = new WP_Query(array(
            'post_type' => 'artist',
            'orderby' => 'title',
            'order' => ASC,
        ));

        while ($agendaHome->have_posts()) {
            $agendaHome->the_post(); ?>
            <ul>
                <li>
                    <button class="agenda-btn" data-toggle="collapse" data-target="#<?php the_title(); ?>"><?php the_title(); ?></button>
                    <div id="<?php the_title(); ?>" class="collapse">
                        <?php the_field('agenda'); ?>
                    </div>
                </li>
            </ul>           
        <?php }
        ?>


    </div>
</div>

Any suggestions?

  • most likely a css issue and not a WP issue. does it work with just dummy content inside of the col-md-6 – NickFMC Feb 5 at 17:30
  • yes! it works perfectly without the php – lulufv Feb 5 at 17:35
0

Not sure how your final html should look, but I guess it's:

<ul>
    <li>...</li>
    <li>...</li>
    <li>...</li>
</ul>

In that case, you should move the ul element outside the while loop and your code should look like this:

<ul>
<?php while ($agendaHome->have_posts()) {
            $agendaHome->the_post(); ?>
    <li>rest of the code goes here</li>
<?php } ?>
</ul>

Also add apostrophes around ASC at the order parameter.

'order' => 'ASC'
  • thank you so much!! that worked – lulufv Feb 5 at 18:02

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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