From 02dea9de0442f5fefcdb665f8fd00de7f999432c Mon Sep 17 00:00:00 2001 From: David Beniamine <david.beniamine@tetras-libre.fr> Date: Thu, 24 Jan 2019 15:18:14 +0100 Subject: [PATCH] =?UTF-8?q?Show=20post=20from=20cat=C3=A9gories?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- posts.php | 35 +++++++++++++++++++++++------------ single_category.php | 10 ++++++++++ 2 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 single_category.php diff --git a/posts.php b/posts.php index b216c03..414ed21 100644 --- a/posts.php +++ b/posts.php @@ -4,18 +4,29 @@ <?php if(has_posts()): ?> <ul class="items"> - <?php posts(); ?> - <li> - <h1> Dernier article </h1> - <?php include("single_article.php"); ?> - </li> - <h1> Articles précédents </h1> - <?php $i = 0; while(posts()): ?> - <?php $bg = sprintf('background: hsl(132, 22%%, %d%%);', round(((++$i / posts_per_page()) * 20) + 20)); ?> - <li style="<?php echo $bg; ?>"> - <?php include("single_article.php"); ?> - </li> - <?php endwhile; ?> + <?php posts(); ?> + <li> + <h1> Dernier article </h1> + <?php include("single_article.php"); ?> + </li> + <li style="background:none"> + <h1> Catégories d'articles </h1> + <?php $i = 0; while(categories()): ?> + <?php $bg = sprintf('background: hsl(131, 6%%, %d%%);', round(50-((++$i / posts_per_page()) * 20))); ?> + <li style="<?php echo $bg; ?>"> + <?php include("single_category.php"); ?> + </li> + </li> + <?php endwhile; ?> + <li style="background:none"> + <h1> Articles précédents </h1> + <?php $i = 0; while(posts()): ?> + <?php $bg = sprintf('background: hsl(131, 6%%, %d%%);', round(50-((++$i / posts_per_page()) * 20))); ?> + <li style="<?php echo $bg; ?>"> + <?php include("single_article.php"); ?> + </li> + </li> + <?php endwhile; ?> </ul> <?php if(has_pagination()): ?> diff --git a/single_category.php b/single_category.php new file mode 100644 index 0000000..3d39ad5 --- /dev/null +++ b/single_category.php @@ -0,0 +1,10 @@ +<article class="wrap"> + <div class="col-md-6 col-sd-12"> + <h2 style="padding:0px"> + <a href="<?php echo category_url(); ?>" title="<?php echo category_title(); ?>"><?php echo category_title(); ?></a> + </h2> + </div> + <div class="contents"> + <?php echo category_description(); ?> + </div> +</article> -- GitLab