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?
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?
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
@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
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
check for slug or url of the page and post. If there is page with the same name then it will query about the page.
Found the solution after determining the right terms to search for here: Display all posts in a custom post type, grouped by a custom taxonomy
EDIT: Instead of all that, you could just use a meta_query and “NOT IN” to exclude the feature stories from your second query. That’s the easiest answer. Check out this meta query documentation for help. 1, you need to have do_not_duplicate be a global array in order access it across functions (pretty sure). 2, you … Read more
Alright, problem solved. Turned out to be a pretty basic mistake, actually. All I needed to do was to pass on the queried term as a second parameter in get_field();. I even posted a comment here referencing one of ACF´s docs that explains just that… Turns out I ALREADY had created the taxonomy array $collections, … Read more
You can use a single loop to achieve this by storing the title/content in your first loop and then just displaying it outside between your div. This way you do not need to loop same thing twice, which ultimately reduce your load time. <?php /** * Work template file. * * This is the most … Read more
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