I have a post with a category of blog .
So i came across with this archieve.php , whereby we can edit the layout and content of a custom post type.
From what I understand archieve.php contains the post meta details of a posts such as category, tags and so on. Please correct me if i am wrong.
However, right now what is affecting the custom post type is a file called single.php
From what I have researched, they told me to go to Settings -> Permalinks and choose Post name
However i have choose that option and it still doesn't work
archive.php
<?php get_header();?>
<h2>Welcome to archieve</h2> //This is not loading in the post page
<div class="container pt-5 pb-5 ">
<h1>right now</h1>
<h1>
<?php
single_cat_title();
if( have_posts() ) {
while( have_posts() ) {
the_post();
}
}
?>
<p></p>
</h1>
</div>
<?php get_footer();?>
single.php
<?php get_header();?>
<h2>Welcome to single</h2> // This is loading in the post page
<div class="container pt-5 pb-5 ">
<h1>
<?php
if( have_posts() ) {
while( have_posts() ) {
the_post();
the_content();
the_permalink();
}
}
?>
<p></p>
</h1>
</div>
<?php get_footer();?>
Results
Kindly advise on this.
Thank you very much for the all the advise given,
I have a post with a category of blog .
So i came across with this archieve.php , whereby we can edit the layout and content of a custom post type.
From what I understand archieve.php contains the post meta details of a posts such as category, tags and so on. Please correct me if i am wrong.
However, right now what is affecting the custom post type is a file called single.php
From what I have researched, they told me to go to Settings -> Permalinks and choose Post name
However i have choose that option and it still doesn't work
archive.php
<?php get_header();?>
<h2>Welcome to archieve</h2> //This is not loading in the post page
<div class="container pt-5 pb-5 ">
<h1>right now</h1>
<h1>
<?php
single_cat_title();
if( have_posts() ) {
while( have_posts() ) {
the_post();
}
}
?>
<p></p>
</h1>
</div>
<?php get_footer();?>
single.php
<?php get_header();?>
<h2>Welcome to single</h2> // This is loading in the post page
<div class="container pt-5 pb-5 ">
<h1>
<?php
if( have_posts() ) {
while( have_posts() ) {
the_post();
the_content();
the_permalink();
}
}
?>
<p></p>
</h1>
</div>
<?php get_footer();?>
Results http://prntscr/mkhczg
Kindly advise on this.
Thank you very much for the all the advise given,
The single.php
template is loaded when you visit a post. The archive.php
page is a generic archive template, loaded in case a grouping of posts (a year, a month, a category, a tag, etc.) does not have it's own template.
Please read this about template hierarchy.
If you want to create a custom post template for a specific post_type
you have to create a dedicated template and call if single-post_type.php
(replace post_type
with your post type, i.e. product
).