Skip to content

Commit

Permalink
handle post type pages
Browse files Browse the repository at this point in the history
  • Loading branch information
stephin-gasper committed Jan 31, 2024
1 parent 892fab5 commit fb7261c
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 0 deletions.
46 changes: 46 additions & 0 deletions home.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* The main template file.
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package Enskill
*/
get_header();
?>

<main id="main" class="site-main content content-wrap" role="main">

<?php
if (have_posts()) :

/* Start the Loop */
while (have_posts()) : the_post();

/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part('template-parts/content', 'post');

endwhile;

the_posts_navigation();

else :

get_template_part('template-parts/content', 'none');

endif;
?>

</main><!-- #main -->

<?php
get_footer();
32 changes: 32 additions & 0 deletions single-post.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* The template for displaying all single posts.
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
*
* @package Enskill
*/
get_header();
?>

<main id="main" class="site-main content content-wrap" role="main">

<?php
while (have_posts()) : the_post();

get_template_part('template-parts/content', 'post');

the_post_navigation();

// If comments are open or we have at least one comment, load up the comment template.
if (comments_open() || get_comments_number()) :
comments_template();
endif;

endwhile; // End of the loop.
?>

</main><!-- #main -->

<?php
get_footer();
49 changes: 49 additions & 0 deletions template-parts/content-post.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* Template part for displaying posts.
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package Enskill
*/

?>

<article id="post-<?php the_ID(); ?>" <?php post_class('row'); ?> itemscope="" itemtype="http://schema.org/BlogPosting" itemprop="blogPost">
<div class="col-md-12 col-sm-12">
<header class="entry-header">
<?php
if ( is_single() ) {
the_title( '<h2 class="entry-title" itemprop="headline">', '</h2>' );
} else {
the_title( '<h2 class="entry-title" itemprop="headline"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
}

if ( 'post' === get_post_type() ) : ?>
<p class="entry-meta">
<?php enskill_posted_on(); ?>
</p><!-- .entry-meta -->
<?php
endif; ?>
</header><!-- .entry-header -->

<div class="entry-content" itemprop="text">
<?php
the_content( sprintf(
/* translators: %s: Name of current post. */
wp_kses( __( 'Continue reading %s <span class="meta-nav">&rarr;</span>', 'enskill' ), array( 'span' => array( 'class' => array() ) ) ),
the_title( '<span class="screen-reader-text">"', '"</span>', false )
) );

wp_link_pages( array(
'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'enskill' ),
'after' => '</div>',
) );
?>
</div><!-- .entry-content -->

<footer class="entry-footer">
<?php enskill_entry_footer(); ?>
</footer><!-- .entry-footer -->
</div>
</article><!-- #post-## -->

0 comments on commit fb7261c

Please sign in to comment.