Answer the question
In order to leave comments, you need to log in
How to setup Permalink custom post types?
Hello everyone )) Guys, there is a page on Wordpress, the link to it looks like this:
mysite.com/learn/books
I created my post type ( register_post_type() ) - "book". Do I need a link to one book to look like this ? :
mysite.com/learn/books/book-name
Tell me
how to do it?
If you specify when registering your post type: 'rewrite' => ['slug' => 'learn/books', 'with_front' => false]
Links to one book will be correct, but this page is mysite.com/learn/books
will have post_type also book, but should be page !
Answer the question
In order to leave comments, you need to log in
Hello. Strange, I'm fine. Added code:
add_action( 'init', 'my_custom_init' );
function my_custom_init() {
register_post_type( 'book', [
'labels' => [
'name' => 'Книги', // Основное название типа записи
'singular_name' => 'Книга', // отдельное название записи типа Book
'add_new' => 'Добавить новую',
'add_new_item' => 'Добавить новую книгу',
'edit_item' => 'Редактировать книгу',
'new_item' => 'Новая книга',
'view_item' => 'Посмотреть книгу',
'search_items' => 'Найти книгу',
'not_found' => 'Книг не найдено',
'not_found_in_trash' => 'В корзине книг не найдено',
'menu_name' => 'Книги',
],
'public' => true,
'rewrite' => [ 'slug' => 'learn/books' ],
'supports' => [ 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ],
] );
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question