I am constructing a cell website and wish to make use of a customized publish
i used to construct it with Customized Publish Sort UI and obtained the code inside perform.php
first time I attempted it it was okay and dealing however the class base was not displaying within the URL so I modified the code however after the modifications the URL giving 404 error
perform cptui_register_my_cpts() {
/**
* Publish Sort: Telephones.
*/
$labels = [
"name" => __( "Phones", "jnews" ),
"singular_name" => __( "Phone", "jnews" ),
"menu_name" => __( "Phones", "jnews" ),
"all_items" => __( "All Phones", "jnews" ),
];
$args = [
"label" => __( "Phones", "jnews" ),
"labels" => $labels,
"description" => "",
"public" => true,
"publicly_queryable" => true,
"show_ui" => true,
"show_in_rest" => true,
"rest_base" => "",
"rest_controller_class" => "WP_REST_Posts_Controller",
"show_in_menu" => true,
"show_in_nav_menus" => true,
"delete_with_user" => false,
"exclude_from_search" => false,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => true,
"rewrite" => [ "slug" => "brand/%brand%/phone/", "with_front" => false],
'has_archive' => 'model',
"query_var" => true,
"supports" => [ "title", "editor", "thumbnail", "excerpt", "custom-fields", "comments", "post-formats" ],
"taxonomies" => [ "brand" ],
"show_in_graphql" => false,
];
register_post_type( "phone", $args );
}
add_action( 'init', 'cptui_register_my_cpts' );
perform cptui_register_my_taxes_brand() {
/**
* Taxonomy: Manufacturers.
*/
$labels = [
"name" => __( "Brands", "jnews" ),
"singular_name" => __( "Brand", "jnews" ),
];
$args = [
"label" => __( "Brands", "jnews" ),
"labels" => $labels,
"public" => true,
"publicly_queryable" => true,
"hierarchical" => false,
"show_ui" => true,
"show_in_menu" => true,
"show_in_nav_menus" => true,
"query_var" => true,
"rewrite" => [ 'slug' => 'brand', 'with_front' => true, 'hierarchical' => true, ],
"show_admin_column" => false,
"show_in_rest" => true,
"rest_base" => "brand",
"rest_controller_class" => "WP_REST_Terms_Controller",
"show_in_quick_edit" => false,
"show_in_graphql" => false,
];
register_taxonomy( "brand", [ "phone" ], $args );
}
add_action( 'init', 'cptui_register_my_taxes_brand' );
perform tm_brands_post_link( $post_link, $id = 0 ){
$publish = get_post($id);
$phrases = wp_get_object_terms( $post->ID, 'model' );
if( $phrases ){
return str_replace( '%model%' , $phrases[0]->slug , $post_link );
}
return $post_link;
}
add_filter( 'post_type_link', 'tm_brands_post_link', 1, 3 );