single-{post-type}.php otherwise single-{post-type}-{slug}.php will not triggere
-
Hey,
im trying to display my custom posts over the
single-{custom-type}.php
but it will not work.My Custom Post Type:
function cptui_register_my_cpts() { /** * Post Type: Fahrzeuge. */ $labels = array( "name" => __( "Fahrzeuge", "custom-post-type-ui" ), "singular_name" => __( "Fahrzeug", "custom-post-type-ui" ), ); $args = array( "label" => __( "Fahrzeuge", "custom-post-type-ui" ), "labels" => $labels, "description" => "", "public" => true, "publicly_queryable" => true, "show_ui" => true, "delete_with_user" => false, "show_in_rest" => true, "rest_base" => "", "rest_controller_class" => "WP_REST_Posts_Controller", "has_archive" => false, "show_in_menu" => true, "show_in_nav_menus" => true, "exclude_from_search" => false, "capability_type" => "post", "map_meta_cap" => true, "hierarchical" => false, "rewrite" => array( "slug" => "vehicles", "with_front" => true ), "query_var" => true, "supports" => array( "title", "editor", "thumbnail" ), ); register_post_type( "vehicles", $args ); } add_action( 'init', 'cptui_register_my_cpts' );
My Custom Tax:
function cptui_register_my_taxes() { /** * Taxonomy: Fahrzeugkategorien. */ $labels = array( "name" => __( "Fahrzeugkategorien", "custom-post-type-ui" ), "singular_name" => __( "Fahrzeugkategorie", "custom-post-type-ui" ), ); $args = array( "label" => __( "Fahrzeugkategorien", "custom-post-type-ui" ), "labels" => $labels, "public" => true, "publicly_queryable" => true, "hierarchical" => true, "show_ui" => true, "show_in_menu" => true, "show_in_nav_menus" => true, "query_var" => true, "rewrite" => array( 'slug' => 'vehiclecategory', 'with_front' => true, ), "show_admin_column" => true, "show_in_rest" => true, "rest_base" => "vehiclecategory", "rest_controller_class" => "WP_REST_Terms_Controller", "show_in_quick_edit" => true, ); register_taxonomy( "vehiclecategory", array( "vehicles" ), $args ); } add_action( 'init', 'cptui_register_my_taxes' );
My Permalink rule:
/%vehiclecategory%/%postname%/
So, i can access my post via the url
www.domain.tld/vehicles/audi/a4/1-8t-220ps
.
“Audi” and “A4” still custom taxonomies (categories)
– Audi
— A4But
have_posts()
on myindex.php
saysfalse
.Okay, i understand i have to create a
single-vehicles.php
but it doesnt work. So i tried alsosingle-vehicles-vehiclecategory.php
andsingle.php
. No one is calling.Between every rename of file i have flush permalinks while visiting the
/wp-admin/options-permalink.php
and pressed “save”.Any ideas what iam doing wrong?
- The topic ‘single-{post-type}.php otherwise single-{post-type}-{slug}.php will not triggere’ is closed to new replies.