I’m (locally) building a custom theme.
So far I have:
- index.php
- single.php
- page.php
- custom page template called about-page.php
- two different headers: one for default use and one for the single.php
NO functions.php;
NO custom taxonomy;
Permalink settings > Common settings : default
My index.php has a list of posts (all of those belonging to a specified category), when I click on one of those posts I end to the index.php BUT with the right custom header (header I created for the posts, it’s called header-single.php).
So, I’m getting the index.php istead of the single.php
I read around other people had the same problem with the word “year” or some other Reserved Terms. I don’t think it’s my case.
In my home page I have:
<?php
/**
* Template Name: Front Page Template
*/
get_header(); ?>
<nav id="menu">
<ul class="postlist">
<?php
$lastposts = get_posts('numberposts=20&orderby=date&cat=9');
foreach($lastposts as $post) :
setup_postdata($post);
?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a</li>
<?php endforeach; ?>
</ul>
</nav>
<?php get_footer(); ?>
EDIT
Here’s the structure of my single.php
<?php
/*
Template Name: Single project
*/
get_header(); ?>
<div id="flex-container">
//something
</div>
<div id="read">
<a>READ</a>
</div>
<div id="read_slider">
<div id="read_close">
<a>CLOSE</a>
</div>
<div id="read_text">
<?php the_content(); ?>
</div>
</div>
</div>
<?php get_footer(); ?>
Your structures is completely wrong. Remove the template name from your
index.php
andsingle.php
templates. You only should use those if you create a custompage.php
template to let wordpress know it is a custom page. This should apply to yourabout-page.php
, which is also wrongly named, it should bepage-about.php
. Yourindex.php
looks about right, but yoursingle.php
is bit of a mess, that is why wordpress skip that template completely and usesindex.php
instead.There is no loop defined in your
single.php
. The loop looks something like this:Go and have a look at the default themes in the WordPress core and see how their templates are put together and how your structures should look like. Working from those themes will guide you in the right direction
I had the same problem with neither the
single-CUSTOM-TYPE.php
nor thesingle.php
being rendered after clicking the single-post-link…. onlyindex.php
instead of the correct file…What helped me was a simple change back to Standard Permalinks in “Settings” -> “Permalinks” and a restore back to “Name of the Post” (Beitragsname)….
Maybe this might help someone else as well
I followed the advices but nothing is working.
My
single.php
is now literally: