• johnbeardy

    (@johnbeardy)


    I’ve a custom post type which is displayed through a single-post-type file.

    I don’t want to display the slug in the URL, and this VIP WordPress hack almost works. “Almost” is because it removes the slug and doesn’t break general post/page permalinks, but the custom posts are now displaying as blank, as if single-post-type is no longer being called.

    How can I get the slug-less page to call the single-post-type?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Yep, suppressing the post type slug causes the template loader to not know the correct template. You need to help it along by filtering ‘template_include’. Get the queried object from the global $wp_query and check the post type of the returned object. If it’s your CPT return the path to the proper template.

    Thread Starter johnbeardy

    (@johnbeardy)

    Thanks, that confirms what I was trying – though with template_redirect rather than template_include.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom post types, slugs, single-post-type template’ is closed to new replies.