I have have added a custom post type called "Blog" by adding the following code to my functions.php
theme file:
function create_posttype() {
register_post_type( 'blog',
array(
'labels' => array(
'name' => __( 'Blog' ),
'singular_name' => __( 'Blog' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'blog'),
'taxonomies' => array( 'category' ),
)
);
}
add_action( 'init', 'create_posttype' );
This has works fine, when viewing www.mysite.co.za/blog/
, this page shows all of my posts. However, when I view a category page such as www.mysite.co.za/category/blog/tips/
it displays no posts. This despite having (1) next to the category name displayed in the sidebar and having "This entry was posted on 03 August 2018 under Tips" at the bottom of the post.
Here is the category.php
template file:
<?php get_header(); ?>
<div id="wrap">
<div id="content" class="column">
<hr class="split style-two">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="post-header">
<h1><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
<p class="subhead"> Posted by <?php the_author_posts_link(); ?> on <?php the_time( 'd M Y' ); ?> under <?php the_category(', ') ?>
<!--<div class="date"><?php the_time( 'M j y' ); ?></div>
<div class="author"><?php the_author(); ?></div>-->
</div><!--end post header-->
<div class="entry clear">
<div class="image-frame">
<a href="<?php the_permalink(); ?>"><?php if ( function_exists( 'add_theme_support' ) ) the_post_thumbnail(); ?></a>
</div>
<?php the_content('<br><span class="moretext">Read More</span>'); ?>
<?php wp_link_pages(); ?>
</div><!--end entry-->
<div class="post-footer">
<div class="comments"><?php comments_popup_link( 'Leave a Comment', '1 Comment', '% Comments', 'commentbutton' ); ?></div>
</div><!--end post footer-->
</div><!--end post--><br><hr class="split style-two">
<?php endwhile; /* rewind or continue if all posts have been fetched */ ?>
<div class="navigation index">
<div class="alignleft"><?php next_posts_link( 'Older Entries' ); ?></div>
<div class="alignright"><?php previous_posts_link( 'Newer Entries' ); ?></div>
</div><!--end navigation-->
<?php else : ?>
<?php endif; ?>
</div>
<div id="sidebar" class="column">
<?php get_sidebar(); ?>
</div>
</div>
</div>
<?php get_footer(); ?>
What is causing the category page to not display any posts?
Thanks in advance
Willem