category-adherent.php 2.34 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
<?php

//nombre de membres à afficher par ligne
$maxMembersPerLine = 3;

get_header();

?>
    <div class="wrap">
        <div id="primary" class="content-area">
            <main id="main" class="site-main" role="main">
N. Peraldi's avatar
N. Peraldi committed
12
                <ul id="adullact-member-list">
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
                    <?php
                    global $post; //variable wp
                    $order = "asc";

                    //on récup le nom de la catégorie de l'url
                    $category = explode("/", $_SERVER['REQUEST_URI'])[2];

                    //on récup le tri croissant / décroissant
                    if (isset($_GET["order"])) {
                        $order = $_GET["order"];

                        if ($order != "asc" && $order != "desc") {
                            $order = "asc";
                        }
                    }

N. Peraldi's avatar
N. Peraldi committed
29
                    $args = array('posts_per_page' => 10, 'offset' => 0, 'category_name' => $category, 'orderby' => 'title', 'order' => $order);
30 31 32 33 34 35
                    $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");

N. Peraldi's avatar
N. Peraldi committed
36 37 38
                    ?>
                </ul>
                <?php
39

N. Peraldi's avatar
N. Peraldi committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
                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>

                    <?php
                    if ($count >= $maxMembersPerLine) {
                        $count = 0;
                        echo "</div>";
                        echo "<div class='adullact-line'>";
                    }

                endforeach;
                echo "</div></div>";

                wp_reset_postdata(); ?>
66 67 68 69 70 71

            </main>
        </div>
    </div>

<?php get_footer(); ?>