Render a loop in Timber (twig for WordPress)

@Xroad, here’s the simplest way. Things can get a bit more complicated depending on the specifics, but this is the most straightforward way: $query = get_posts(array(‘post_type’ => ‘lexique’,’posts_per_page’ => -1)); $by_letter = array(); while( $query->have_posts() ) { $query->the_post(); global $post; $letter = substr($post->post_name, 0, 1); if ( ! isset($by_letter[$letter]) ) $by_letter[$letter] = array(); $by_letter[$letter][] = … Read more

How do I display 3 post each in a bootstrap carousel?

A div with class=”item” is used for each carousel slide. But right now your foreach loop is inside that div, not outside, so all of your posts are going into one slide. So just change that bit to: <div class=”carousel-inner”> <?php foreach ($lastposts as $post) : setup_postdata ($post); ++$index; ?> <div class=”item<?php if ($index == … Read more

WordPress Loop with Custom Post Type for Bootstrap Accordion [closed]

You put the accordion inside the loop, that’s why it is not working as you want. Try this: <?php $args = array( ‘post_type’ => ‘review’ ); $the_query = new WP_Query($args); ?> <div class=”row mb-5″> <div class=”col-md-9″> <div id=”accordion” role=”tablist” aria-multiselectable=”true”> <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : ?> <?php $the_query->the_post(); ?> … Read more

WordPress loop put title into variable

Creating variables on the fly like that is not needed. Just use an array instead. $myvars = []; inside your foreach loop you can: $myvars[] = array(‘title’=>$t,’image’=>$v); After your loop you can: //First title, First image echo $myvars[0][‘title’]; echo $myvars[0][‘image’]; //Second title, Second image echo $myvars[1][‘title’]; echo $myvars[1][‘image’]; This way you can always print_r($myvars) and … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)