WordPress добавляет дефис в пользовательский URL - PullRequest
0 голосов
/ 18 сентября 2018

Я создал собственный тип записи в своем приложении WordPress и хочу, чтобы его URL-адрес разделялся через дефисы. Например, имя пользовательского сообщения - Singh Across The World и в URL singhacrosstheworld, и оно должно быть singh-across-the-world.

.

Я пытался использовать singh-across-the-world / singh_across_the_world вместо singhAcrossTheWorld в качестве первого параметра, но он не работал.

Вот код, пожалуйста, посмотрите:

register_post_type("singhAcrossTheWorld", [
    "capability_type"   => "post",
    "description"       => "Holds our Singh's specific data",
    "public"            => true,
    "menu_position"     => 6,
    "has_archive"       => true,
    "show_admin_column" => true,
    "supports"          => [
        "title",
        "editor",
        "thumbnail",
        "excerpt",
        "revisions",
        "comments",
        "custom-fields",
        "page-attributes"
    ],
    "taxonomies"        => [
        "post_tag"
    ],
    "labels" => [
        "name"               => "Singh across the world",
        "singular_name"      => "Singh across the world",
        "add_new"            => "Add Singh",
        "add_new_item"       => "Add Singh",
        "edit_item"          => "Edit Singh",
        "new_item"           => "New Singh",
        "all_items"          => "All Singhs",
        "view_item"          => "View Singh",
        "search_items"       => "Search Singhs",
        "not_found"          => "No Singhs found",
        "not_found_in_trash" => "No Singhs found in the Trash",
        "parent_item_colon"  => "",
        "menu_name"          => "S. A. T. W."
    ]
]);

1 Ответ

0 голосов
/ 18 сентября 2018

добавить это аргументы rewrite' => array( 'slug' => 'singh-across-the-world' )

register_post_type("singhAcrossTheWorld", [
    "capability_type"   => "post",
    "description"       => "Holds our Singh's specific data",
    "public"            => true,
    "menu_position"     => 6,
    "has_archive"       => true,
    "show_admin_column" => true,
    "supports"          => [
        "title",
        "editor",
        "thumbnail",
        "excerpt",
        "revisions",
        "comments",
        "custom-fields",
        "page-attributes"
    ],
    "taxonomies"        => [
        "post_tag"
    ],
    "labels" => [
        "name"               => "Singh across the world",
        "singular_name"      => "Singh across the world",
        "add_new"            => "Add Singh",
        "add_new_item"       => "Add Singh",
        "edit_item"          => "Edit Singh",
        "new_item"           => "New Singh",
        "all_items"          => "All Singhs",
        "view_item"          => "View Singh",
        "search_items"       => "Search Singhs",
        "not_found"          => "No Singhs found",
        "not_found_in_trash" => "No Singhs found in the Trash",
        "parent_item_colon"  => "",
        "menu_name"          => "S. A. T. W."
    ],
    'rewrite' => array(
                'slug' => 'singh-across-the-world'
    )
]);
...