Loop displays current page

All other things being equal, your page file “page-projets.php” will display a page with a slug = “projets”. So… what is the contents of that page?

Question about custom plugin

You should change your get_posts to WP_Query. You are making a lot of queries because you’re running setup_postdata is running its own set of queries to get the post data from the posts you got through get_posts. This can be avoided by using WP_Query instead. Based on your code, you should have something like this … Read more

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