• Resolved vbosch

    (@vbosch)


    I’m building my own WordPress theme and I included a custom post type in this theme.
    When visiting any type of post the index.php is being used as a template instead of the single.php file.

    I get the following error when looking at posts in my /wp-admin page: (/app/public/wp-content/themes/VanderVeer thema/single.php): failed to open stream: No such file or directory in /app/public/wp-includes/class-wp-theme.php on line 1018

    A few solutions people on the internet adviced to do that haven’t worked yet:
    Visiting/saving the permalinks page.
    Restarting my server (I’m working on a local server)
    Reinstalling WordPress and import the theme.

    All of these options didn’t work for me and I can’t find other solutions.

    My archive.php is working and I have tried different single.php files so I don’t think the error is within these files of my theme.

    • This topic was modified 6 years, 4 months ago by vbosch.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    A custom post type should use single-cptslug.php as its template file, with failover ot single.php then index.php. Given the error (no such file), I wonder if the blank in the theme directory name is the issue.

    Thread Starter vbosch

    (@vbosch)

    I removed the blank space in the theme directory name and it seems to be fixed. I didn’t know this would give trouble.

    Thank you for your help!

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Dang! Sometimes my wild guesses are right. ??

    Thread Starter vbosch

    (@vbosch)

    Update:

    I guess this was a temporary fix. After changing the directory name and refreshing the page my posts were using the single.php file, but after a while they stopped using it and now they’re using the index.php file again.

    Same error code (only without a blank space in the directory name): (/app/public/wp-content/themes/VanderVeerthema/single.php): failed to open stream: No such file or directory in /app/public/wp-includes/class-wp-theme.php on line 1018 ??

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Things don’t work then not work unless you do something in-between.

    >> I’m building my own WordPress theme <<

    Did you build this on one of the solid foundations, like https://underscores.me?

    Thread Starter vbosch

    (@vbosch)

    No it’s actually completely build from scratch and I’ve done that before. Usually all my codes and plugins work, never had trouble with such things.

    I could try rebuilding the theme on a solid foundation.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Whenever making changes to a custom post type definition, you need to re-save your permalinks.

    Thread Starter vbosch

    (@vbosch)

    I’ve done that a lot of times already but unfortunately this doesn’t work for me.

    Thread Starter vbosch

    (@vbosch)

    All of sudden works steady again. Could’ve been a problem with cache or something. Thanks for your time!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Posts use index.php instead of single.php’ is closed to new replies.