Hiển thị các thuộc tính bài viết, tác giả, ngày tháng, danh mục, bình luận | structure-posts.php

23 Jul 2020
0 Comments
                
                    
function the_post_meta()
{
    ?>
    <p class="post-meta">
        <?php if (is_single()): ?>
            <span class="post-meta-author">
                    <i class="fas fa-user"></i><?php the_author(); ?>
                </span>
            <span class="fs-date">
                    <i class="fas fa-clock"></i><?php echo get_the_date(); ?>
                </span>
            <span class="post-cats">
                    <i class="fas fa-folder"></i><?php echo get_the_category_list(__(', ', 'flatsome')); ?>
                </span>
            <?php if (comments_open()) { ?>
                <span class="post-comments">
                    <i class="fas fa-comment-alt"></i><?php echo get_comments_number(); ?>
                </span>
            <?php } ?>
            <span class="post-views"><i class="fas fa-eye"></i>51,772 Views</span>
            <?php //echo do_shortcode('[kkratings]'); ?>
        <?php else: ?>
            <span class="fs-date">
                    <i class="fas fa-clock"></i><?php echo get_the_date(); ?>
                </span>
        <?php endif; ?>
    </p>
    <?php
}
                
            

wp-content/themes/flatsome-child/template-parts/posts/partials/entry-header.php

                
                    
<header class="entry-header">
   <div class="entry-header-text entry-header-text-top pb-0 text-<?php echo get_theme_mod( 'blog_posts_title_align', 'center' ); ?>">
      <?php get_template_part( 'template-parts/posts/partials/entry', 'title' ); ?>
   </div>
   <?php if ( has_post_thumbnail() ) : ?>
      <?php if ( ! is_single() || ( is_single() && get_theme_mod( 'blog_single_featured_image', 1 ) ) ) : ?>
         <div class="entry-image relative">
            <?php get_template_part( 'template-parts/posts/partials/entry-image', 'default' ); ?>
            <?php if ( get_theme_mod( 'blog_badge', 1 ) ) get_template_part( 'template-parts/posts/partials/entry', 'post-date' ); ?>
         </div>
      <?php endif; ?>
   <?php endif; ?>
</header>
                
            

wp-content/themes/flatsome-child/template-parts/posts/partials/entry-title.php

                
                    
<?php
if (is_single()) {
    echo '<h1 class="entry-title">' . get_the_title() . '</h1>';
    the_post_meta();
} else {
    echo '<h2 class="entry-title"><a href="' . get_the_permalink() . '" rel="bookmark" class="plain">' . get_the_title() . '</a></h2>';
}
?>

<?php
$single_post = is_singular('post');
if ($single_post && get_theme_mod('blog_single_header_meta', 1)) : ?>
    <div class="entry-meta uppercase is-xsmall">
        <?php flatsome_posted_on(); ?>
    </div>
<?php elseif (!$single_post && 'post' == get_post_type()) : ?>
    <div class="entry-meta uppercase is-xsmall">
        <?php flatsome_posted_on(); ?>
    </div>
<?php endif; ?>
                
            

wp-content/themes/flatsome-child/change/assets/css/items/_post-meta.scss

                
                    
.post-meta {
  @include fontSize(14px);
  > span {
    &:not(:last-child) {
      margin-right: 15px;
    }

    i {
      margin-right: 5px;
    }
  }

  .post-meta-author {
    i{
      color: $primary;
    }
  }

  .fs-date {
    i{
      color: $secondary;
    }
  }

  .post-cats {
    display: none;
  }

  .post-comments {
    display: none;
  }

  .post-views {
    display: none;
  }
}
                
            

Leave a Reply

This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.