L
L
lexstile2018-07-06 09:59:20
WordPress
lexstile, 2018-07-06 09:59:20

How to create a template for news in WP?

I can't understand, I'm trying like category-
{slug}.php - If the category's slug were news, WordPress would look for category-news.php
category-{id}.php - If the category's ID were 6, WordPress would look for category-6.php
category.php
archive.php
index.php
tried everything, only index.php works
, what could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan Hasanli, 2018-07-06
@azerphoenix

Hello!
The category, archive templates are designed to display a cycle of records. To display the post itself, you need the single.php template
A simple single.php template:

<?php get_header();?>
<div class="content">
<h1><?php the_title();?></h1>
<?php the_content();?>
</div>
<?php get_footer();?>

Simple template for archive || categories.php
<?php get_header();?>
<div class="content">
<?php if (have_posts()) :  while (have_posts()) : the_post(); ?>
       <h3><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h3>
<?php the_excerpt();?>
<?php endwhile; ?>
<?php endif; ?>
</div>
<?php get_footer();?>

And then style it to suit your needs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question