Compare commits

...

2 commits

Author SHA1 Message Date
Kazhnuz
2cfaf89b3f feat: new homepage
Fixes #4
2021-01-02 19:31:24 +01:00
Kazhnuz
8e7a93afa6 fix: show social only on articles 2021-01-01 21:54:08 +01:00
4 changed files with 45 additions and 34 deletions

View file

@ -1,40 +1,34 @@
<div id="featured-articles" class="preview-container"> <div id="featured-articles">
<?php <?php
query_posts(array( query_posts(array(
'post_type' => 'post', 'post_type' => 'post',
'tax_query' => array( 'tax_query' => array(
array( array(
'taxonomy' => 'niveau', 'taxonomy' => 'category',
'terms' => 'featured', 'terms' => 'blog',
'field' => 'slug', 'field' => 'slug',
) )
), ),
'orderby' => 'date', 'orderby' => 'date',
'post_count' => '2', 'post_count' => '1',
'order' => 'DESC' 'order' => 'DESC',
'posts_per_page' => '1'
)); ));
if ( have_posts() ) while ( have_posts() ) : the_post(); ?> if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<article class="preview"> <div class="card card-primary" id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink(); ?>" class="preview-link"> <div class="card-header"><h1><?php the_title(); ?></h1></div>
<div class="preview-item" style="background-image:url('<?php echo get_the_post_thumbnail_url(); ?>');"> <div class="flex-that mb">
<div class="preview-overlay"> <div class="article-category">
<div class="preview-categories"> <?php $category = get_the_category();
<?php $category = get_the_category(); echo"<a href= '" . esc_url( get_category_link( $category[0]->term_id ) ) . "' class='btn-small btn-info'><i class='fa fa-folder'></i> " . $category[0]->cat_name . "</a>"; ?>
echo"<span class='badge badge-category'>" . $category[0]->cat_name . "</span>"; ?> </div>
</div> <time itemprop="datePublished"><em><?php the_time('j F Y') ?></em></time>
</div>
<h2 class="preview-title"><?php the_title();/*3*/ ?></h2> <?php the_excerpt(); ?>
</div> <p class="align-center"> <a href="<?php the_permalink(); ?>" class="btn btn-readmore" title="<?php the_title();?>">Lire l'article</a> </p>
</div> </div>
</a>
</article>
<?php endwhile; ?> <?php wp_reset_query(); /*4*/ ?> <?php endwhile; ?> <?php wp_reset_query(); /*4*/ ?>
</div> </div>

View file

@ -60,7 +60,7 @@ function mypost_social_sharing_buttons($content) {
// https://mypost_.com/how-to-create-social-sharing-button-without-any-plugin-and-script-loading-wordpress-speed-optimization-goal/ // https://mypost_.com/how-to-create-social-sharing-button-without-any-plugin-and-script-loading-wordpress-speed-optimization-goal/
global $post; global $post;
if(is_singular() || is_home()){ if(is_singular() && !is_page()){
// Get current page URL // Get current page URL
$mypost_URL = urlencode(get_permalink()); $mypost_URL = urlencode(get_permalink());

20
home.php Normal file
View file

@ -0,0 +1,20 @@
<?php get_header(); ?>
<main class="col-md-8">
<!-- Recuperation de la page de home -->
<?php if ( !is_paged() ) {
$page = get_page_by_path( 'home' );
if ($page != null) {
echo '<h1 class="page-title">' . get_the_title( $page ) . '</h1>';
echo '<div>' . $page->post_content . '</div>';
}
echo '<h1 class="page-title">Dernier article</h1>';
include(TEMPLATEPATH . '/components/featured.php');
}
?>
<h1 class="page-title">Publications</h1>
<?php include(TEMPLATEPATH . '/components/preview-list.php'); ?>
</main>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

View file

@ -1,10 +1,7 @@
<?php get_header(); ?> <?php get_header(); ?>
<main class="col-md-8"> <main class="col-md-8">
<h1 class="page-title"><i class="fa fa-fw fa-star"></i> À la une</h1> <h1 class="page-title">Publications</h1>
<?php include(TEMPLATEPATH . '/components/featured.php'); ?> <?php include(TEMPLATEPATH . '/components/preview-list.php'); ?>
<h1 class="page-title"><i class="fa fa-fw fa-clock-o"></i> Articles récents</h1>
<?php include(TEMPLATEPATH . '/components/posts-list.php'); ?>
</main> </main>
<?php get_sidebar(); ?> <?php get_sidebar(); ?>
<?php get_footer(); ?> <?php get_footer(); ?>