Browse Source

feat(single): add a way to hide main title

main
Kazhnuz Klappsthul 9 months ago
parent
commit
4dfaa90630
  1. 72
      components/article.php
  2. 14
      single-notitle.php
  3. 71
      single.php

72
components/article.php

@ -0,0 +1,72 @@
<div class="flex-that">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class='breadcrumb-item'><a href='<?php echo site_url(); ?>'>kazhnuz.space</a></li><?php $categories = get_the_category();
foreach( $categories as $category ) {
echo "<li class='breadcrumb-item'><a href='" . esc_url( get_category_link( $category->term_id ) ) . "'><i class='fa fa-folder-open'></i> " . $category->cat_name . "</a></li>";
} ?><li class="breadcrumb-item" aria-current="page"><span class="active"><i class="fa fa-file"></i> <?php echo the_title(); ?></span></li>
</ol>
</nav>
</div>
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<?php $flags = get_the_terms($post->ID, 'flag');
if ($flags) {
foreach( $flags as $flag ) {
$term_meta = get_option( "taxonomy_term_$flag->term_id" );
echo "<div class='toast toast-" . $term_meta['niveau'] . "'>";
echo $flag->description;
echo "</div>";
}
} ?>
<article class="article container-article" id="post-<?php the_ID(); ?>">
<?php if ($haveTitle) { ?>
<h1 class="page-title"><?php the_title(); ?></h1>
<?php } ?>
<div class="article-entry">
<?php the_content(); ?>
</div>
</article>
<section class="card card-noheader">
<div class="author-area">
<? echo get_avatar( get_the_author_meta('user_email'), $size = '120'); ?>
<div class="author-metadata">
<div class="author-pseudo">Écrit par <a href="https://kazhnuz.space"><?php the_author() ?></a></div>
<small class="author-date">Le <?php the_time('l j F Y à H:i') ?></small>
</div>
</div>
<?php
$custom_fields = get_post_custom();
$my_custom_field = $custom_fields['description'];
if ($my_custom_field != null) {
foreach ( $my_custom_field as $key => $value ) {
echo " <div class='card-body'> " . $value . "</div>";
}
}
?>
<div class="article-category">
<?php $categories = get_the_category();
foreach( $categories as $category ) {
echo "<a href= '" . esc_url( get_category_link( $category->term_id ) ) . "' class='btn-small btn-info'><i class='fa fa-folder'></i> " . $category->cat_name . "</a>";
} ?>
<?php $tags = get_the_tags();
if ($tags) {
foreach( $tags as $tag ) {
echo "<a href= '" . esc_url( get_tag_link( $tag->term_id ) ) . "' class='btn-small btn-primary'><i class='fa fa-tag'></i> " . $tag->name . "</a> ";
}
} ?>
</div>
</section>
<?php comments_template(); ?>
<?php endwhile; ?>
<?php endif; ?>

14
single-notitle.php

@ -0,0 +1,14 @@
<?php get_header();
/*
Template Name: no-title-article
Template Post Type: post
*/
?> <!-- ouvrir header,php -->
<main>
<?php $haveTitle = false; ?>
<?php include(TEMPLATEPATH . '/components/article.php'); ?>
</main>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

71
single.php

@ -1,76 +1,9 @@
<?php get_header(); ?> <!-- ouvrir header,php -->
<main>
<div class="flex-that">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class='breadcrumb-item'><a href='<?php echo site_url(); ?>'>kazhnuz.space</a></li><?php $categories = get_the_category();
foreach( $categories as $category ) {
echo "<li class='breadcrumb-item'><a href='" . esc_url( get_category_link( $category->term_id ) ) . "'><i class='fa fa-folder-open'></i> " . $category->cat_name . "</a></li>";
} ?><li class="breadcrumb-item" aria-current="page"><span class="active"><i class="fa fa-file"></i> <?php echo the_title(); ?></span></li>
</ol>
</nav>
</div>
<?php $haveTitle = true; ?>
<?php include(TEMPLATEPATH . '/components/article.php'); ?>
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<?php $flags = get_the_terms($post->ID, 'flag');
if ($flags) {
foreach( $flags as $flag ) {
$term_meta = get_option( "taxonomy_term_$flag->term_id" );
echo "<div class='toast toast-" . $term_meta['niveau'] . "'>";
echo $flag->description;
echo "</div>";
}
} ?>
<article class="article container-article" id="post-<?php the_ID(); ?>">
<h1 class="page-title"><?php the_title(); ?></h1>
<div class="article-entry">
<?php the_content(); ?>
</div>
</article>
<section class="card card-noheader">
<div class="author-area">
<? echo get_avatar( get_the_author_meta('user_email'), $size = '120'); ?>
<div class="author-metadata">
<div class="author-pseudo">Écrit par <a href="https://kazhnuz.space"><?php the_author() ?></a></div>
<small class="author-date">Le <?php the_time('l j F Y à H:i') ?></small>
</div>
</div>
<?php
$custom_fields = get_post_custom();
$my_custom_field = $custom_fields['description'];
if ($my_custom_field != null) {
foreach ( $my_custom_field as $key => $value ) {
echo " <div class='card-body'> " . $value . "</div>";
}
}
?>
<div class="article-category">
<?php $categories = get_the_category();
foreach( $categories as $category ) {
echo "<a href= '" . esc_url( get_category_link( $category->term_id ) ) . "' class='btn-small btn-info'><i class='fa fa-folder'></i> " . $category->cat_name . "</a>";
} ?>
<?php $tags = get_the_tags();
if ($tags) {
foreach( $tags as $tag ) {
echo "<a href= '" . esc_url( get_tag_link( $tag->term_id ) ) . "' class='btn-small btn-primary'><i class='fa fa-tag'></i> " . $tag->name . "</a> ";
}
} ?>
</div>
</section>
<?php comments_template(); ?>
<?php endwhile; ?>
<?php endif; ?>
</main>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Loading…
Cancel
Save