Saturday, August 27, 2022
HomeWordPress Developmentcustomized submit varieties - How do I be certain that post_type and...

customized submit varieties – How do I be certain that post_type and Taxonomy use the identical slug?


I needed to create a Customized Publish Sort and taxonomy so as to add a query and reply part to my website. However I would like each of them to make use of the identical persistent hyperlink. The codes are like this, so one of many two does not work, how can I cease them from blocking one another?

The use I would like it to be;
Customized Publish Tyle: websitename.com/question-answer/question-title
Taxonomi: websitename.com/question-answer/category-name

perform post_type_question_answer() {
    $args = array(
        'labels' => $labels,
        'has_archive' => true,
        'public' => true,
        'hierarchical' => false,
        'taxonomies' => array(
            'question_answer_taxonomi'
        ),
        'rewrite' => array(
            'slug' => 'question-answer'
        ),
        'show_in_rest' => true,
    );
    register_post_type( 'question_answer', $args );
}
add_action( 'init', 'post_type_question_answer' );

register_taxonomy('question_answer_taxonomi', ['question_answer'], [
    'hierarchical' => true,
    'rewrite' => array(
        'slug' => 'question-answer'
    )
]);
register_taxonomy_for_object_type('question_answer_taxonomi', 'question_answer');

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments