category-adherent.php 2.1 KB
Newer Older
1 2
<?php
//nombre de membres à afficher par ligne
Nathan Peraldi's avatar
Nathan Peraldi committed
3
$maxMembersPerLine = 4;
4 5 6 7
get_header();

?>
    <div class="wrap">
Nathan Peraldi's avatar
Nathan Peraldi committed
8 9
        <main id="main" class="site-main" role="main">
            <ul id="adullact-member-list">
10
                <?php
Nathan Peraldi's avatar
Nathan Peraldi committed
11 12
                global $post; //variable wp
                $order = "asc";
13

Nathan Peraldi's avatar
Nathan Peraldi committed
14 15
                //on récup le nom de la catégorie de l'url
                $category = explode("/", $_SERVER['REQUEST_URI'])[2];
16

Nathan Peraldi's avatar
Nathan Peraldi committed
17 18 19
                //on récup le tri croissant / décroissant
                if (isset($_GET["order"])) {
                    $order = $_GET["order"];
20

Nathan Peraldi's avatar
Nathan Peraldi committed
21 22
                    if ($order != "asc" && $order != "desc") {
                        $order = "asc";
23
                    }
Nathan Peraldi's avatar
Nathan Peraldi committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
                }
                $args = array('posts_per_page' => 10, 'offset' => 0, 'category_name' => $category, 'orderby' => 'title', 'order' => $order);
                $myposts = get_posts($args);
                echo "<br>";

                $count = 0; //va servir pour les retour à la ligne lorsqu'on a affiché le max d'éléments par ligne
                childrens_of_member_category("$category");

                ?>
            </ul>
            <?php
            echo "<div class='adullact-members-list'>";
            echo "<div class='adullact-line'>";
            foreach ($myposts as $post) : setup_postdata($post);
                $id = get_the_id();
                $url = get_metadata("post", $id, "project_url")[0];
                $count += 1;
                ?>

                <a href="<?php echo $url; ?>" target="_blank" class="adullact-member">
                    <?php the_post_thumbnail(array("200", "200")); ?> <br>
                    <?php the_title(); ?> <br>
                    <?php the_tags($before = ''); ?>
                </a>
48

Nathan Peraldi's avatar
Nathan Peraldi committed
49 50 51 52 53 54 55 56 57 58 59
                <?php
                if ($count >= $maxMembersPerLine) {
                    $count = 0;
                    echo "</div>";
                    echo "<div class='adullact-line'>";
                }
            endforeach;
            echo "</div></div>";

            wp_reset_postdata(); ?>
        </main>
60 61
    </div>
<?php get_footer(); ?>