$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'); ?>loop - Display posts side by side with custom query|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)

loop - Display posts side by side with custom query

matteradmin8PV0评论

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?

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?

Share Improve this question asked Feb 5, 2019 at 17:25 lulufvlulufv 51 silver badge3 bronze badges 2
  • most likely a css issue and not a WP issue. does it work with just dummy content inside of the col-md-6 – NickFMC Commented Feb 5, 2019 at 17:30
  • yes! it works perfectly without the php – lulufv Commented Feb 5, 2019 at 17:35
Add a comment  | 

1 Answer 1

Reset to default 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'
Post a comment

comment list (0)

  1. No comments so far