category-adherent.php 2.3 KB
Newer Older
N. Peraldi's avatar
N. Peraldi committed
1
<?php get_header(); ?>
2
    <div class="wrap">
N. Peraldi's avatar
N. Peraldi committed
3
        <main id="main" class="site-main" role="main">
N. Peraldi's avatar
N. Peraldi committed
4 5
            <div id="adullact-sort-buttons">
                <div id="adullact-sort-by-type-buttons">
6

N. Peraldi's avatar
N. Peraldi committed
7 8 9 10
                    <ul class="adullact-member-list">
                        <?php
                        global $post; //variable wp
                        $order = "asc";
N. Peraldi's avatar
N. Peraldi committed
11

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

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

N. Peraldi's avatar
N. Peraldi committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
                            if ($order != "asc" && $order != "desc") {
                                $order = "asc";
                            }
                        }

                        $args = array('posts_per_page' => 10, 'offset' => 0, 'category_name' => $category, 'orderby' => 'title', 'order' => $order);
                        $myposts = get_posts($args);


                        $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>
                </div>
                <div id="adullact-sort-by-name">
                    <ul class="adullact-member-list">
                        <?php sort_page() ?>
                    </ul>
                </div>
            </div>
            <?php echo "<div class='adullact-members-list'>";
N. Peraldi's avatar
N. Peraldi committed
41 42 43 44 45 46

            foreach ($myposts as $post) : setup_postdata($post);
                $id = get_the_id();
                $url = get_metadata("post", $id, "project_url")[0];
                $count += 1;
                ?>
N. Peraldi's avatar
N. Peraldi committed
47 48 49 50 51 52 53 54 55 56
                <div class="adullact-member">
                    <div>
                        <a href="<?php echo $url; ?>" target="_blank">
                            <?php the_post_thumbnail(array("200", "200")); ?> <br>
                        </a>
                    </div>

                    <p><?php the_title(); ?></p><br>
                </div>
            <?php endforeach;
N. Peraldi's avatar
N. Peraldi committed
57 58 59
            echo "</div></div>";
            wp_reset_postdata(); ?>
        </main>
60 61
    </div>
<?php get_footer(); ?>