• When I add .html templates in /theme/templates, from the admin pannel it detects them properly, however when I add .php templates it does not.

    I’ve also tried writing the name like this:

    <?php
    /*
    Template Name: Test Page
    */
    
    echo "test page";

    And Also tried putting it in the root of the theme.

    It just does not detect them.

    Help very much appreciated

    Regards,

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter antonicofr

    (@antonicofr)

    Just saw it detects them but only for Pages, not Posts.

    Any way to use it for Posts?

    Moderator bcworkz

    (@bcworkz)

    With classic themes, there’s a specific way to get certain templates used for certain posts by how they are named. But FSE/block themes use a different paradigm. Block themes are still unexplored territory for me, but from looking at Twenty twentythree theme’s file structure, the way we should introduce PHP into a template is via patterns. The main template in /templates/ refers to a template part in /parts/. The template part can then refer to a PHP pattern.

    Maybe a main template can directly refer to a pattern without an intervening part, IDK? looks a little further… yup, we can.

    How to get a specific template used for certain posts? Again, I know how in classic themes, but I’m as lost as you are with block themes. I think the answer lies here:
    https://developer.www.ads-software.com/themes/advanced-topics/theme-json/#defining-custom-templates

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WordPress not detecting template’ is closed to new replies.