P
P
Pavel Didenko2018-06-17 11:49:23
WordPress
Pavel Didenko, 2018-06-17 11:49:23

How to implement child posts to posts in wordpress?

I registered a taxonomy, for example, this one:

register_post_type( 'kosmetologiya',
    array(
      'labels' => array(
        'name' => __( 'Косметология' ),
        'singular_name' => __( 'Косметологические процедуры' )
      ),
      'public' => true,
      'has_archive' => true,
      'add_new' => 'Добавить процедуру',
      'menu_position' => 5,
      'supports' => array('title', 'editor', 'thumbnail', 'post-formats', 'excerpt', 'custom-fields' ),
    )
  );

When creating a record in this type of records, they are displayed like this:
domain.ru/kosmetologiya/biorevitalizaciya/ where biorevitalization is a "record".
Question:
How to implement a child record for the "biorevitalization" record so that it has the following URL type: domain.ru/kosmetologiya/biorevitalizaciya/lica/
Perhaps this will help:
On one of the client sites I saw such an implementation that would also fit.
Here is an example of the page https://creditznatok.com.ua/mikrozaimy/cherez-internet/ this is a record that is created / edited in a separate block of records - here prntscr.com/jsfvvx
And there is such a type of page - https://creditznatok. com.ua/mikrozaimy/cherez-inte...and this is also a record, only it is implemented through a separate record type, here prntscr.com/jsfwfn
The principle by which it is determined that one record is a child of another record is not known, because admin panel apparently limits the ability to view detailed information

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Kozlov, 2018-06-17
@Dasslier

Registration parameters should be like this

register_post_type( 'kosmetologiya',
    array(
      'labels' => array(
        'name' => __( 'Косметология' ),
        'singular_name' => __( 'Косметологические процедуры' )
      ),
      'public' => true,
      'has_archive' => true,
      'add_new' => 'Добавить процедуру',
      'menu_position' => 5,
'hierarchical' => true,
      'supports' => array('title', 'editor', 'thumbnail', 'post-formats', 'excerpt', 'custom-fields', 'page-attributes' ),
    )
  );

This should enable a hierarchical structure similar to pages. If it is not displayed, then check the screen settings when creating the procedure. Also the permalinks must be properly configured as "post title"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question