Hi. I had to create a Custom Post Type and taxonomy to add a question and answer section to my site. But I want both of them to use the same persistent link. The codes are like this, so one of the two doesn’t work, how can I stop them from blocking each other?
The use I want it to be;
Custom Post Tyle: websitename.com/question-answer/question-title
Taxonomi: websitename.com/question-answer/category-name
function 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’);
