• Resolved landongw

    (@landongw)


    I have a problem where a custom post type seems to not be fully registering.

    I have created a set of custom post types using CPT UI. Which works. For example I have “route” and “country”. They show up in my admin and work.

    To create a template for “route” posts I duplicated the following files into my child theme in the same directory:

    1) single.php becomes single-route.php

    2) In single-route.php I updated the code from:

    <?php x_get_view( x_get_stack(), ‘wp’, ‘single’ ); ?>

    to this:

    <?php x_get_view( x_get_stack(), ‘wp’, ‘single-route’ ); ?>

    3) content.php becomes content-route.php

    4) I updated the following code in content-route.php from:

    <?php x_get_view( ‘ethos’, ‘_content’, ‘post-header’ ); ?>
    to this:

    <?php x_get_view( ‘ethos’, ‘_content’, ‘route’, ‘post-header’ ); ?>

    4) wp-single.php becomes wp-single-route.php

    All of that worked, my new template applied to the “route” custom post type.

    Now, a week later, when I repeated that process substituting “country” in place of “route” it does not work for me. The country posts return a 500 error.

    I kind of remember that there was another step I had to go through to force the full registration of the new post types. Is there something I am missing?

    Thanks for any help you can provide.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Not sure what to tell you, to be honest. The biggest question really, is why you’re getting Server 500 errors. I have to believe the “country” post type is being registered properly in the admin, you can create new posts, etc. Is it working fine and everything when you let it fall back to the default files for single.php and such? Without staying a step ahead and making the post type-specific template files?

    In general, when it comes to template files, we’re hands off and don’t touch it at all. That x_get_view() function looks like it’s from the theme itself, and not from WordPress core, so I don’t know anything about it, or what all it may be doing.

    Thread Starter landongw

    (@landongw)

    Yes, it registers in the admin — I can create new posts, and they even show up when I don’t create a new post template for them — the default works fine.

    And yes, x_get_view is from the theme.

    Is there something I can do to cycle the post type registration?

    This line in content-country.php shows “country” as black (not recognized) in my editor:

    <?php x_get_view( ‘ethos’, ‘_content’, ‘country’, ‘post-header’ ); ?>

    It seems like the post type is not registering fully.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    If it’s in the admin, and you can create posts etc, it’s registered as much as can be, as far as I’m aware. I can’t say I’ve ever heard of “partial” registration of post types. It essentially either is already, or is not yet. The “default” templates working, based on the WordPress template hierarchy, is a good sign as well. That said, at this point, it’s feeling like an issue stemming from the theme more than our plugin and what it handles.

    Thread Starter landongw

    (@landongw)

    I’ll follow up with them. Thanks Michael!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Custom Post Type with Template’ is closed to new replies.