$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>problem with custom post type and custom taxonomy url structure|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

problem with custom post type and custom taxonomy url structure

matteradmin12PV0评论

I create a tour custom post type and destination custom taxonomy like this:

<?php
/*********************************************** Create Post Type ***********************************************/
add_action('init', 'create_post_type');
function create_post_type()
{
    register_post_type('tour', array(
        'label' => 'تور',
        'description' => '',
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'show_in_admin_bar' => true,
        'capability_type' => 'post',
        'hierarchical' => true,
        'rewrite' => array('slug' => 'tour', 'with_front' => false,'hierarchical' => true,),
        'query_var' => true,
        'has_archive' => false,
        'exclude_from_search' => false,
        'supports' => array('title', 'editor', 'thumbnail'),
        'taxonomies' => array('destination'),
        'labels' => array(
            'name' => 'تور',
            'singular_name' => 'تور',
            'menu_name' => 'تور',
            'add_new' => 'افزودن تور',
            'add_new_item' => 'افزودن تور',
            'edit' => 'ویرایش',
            'edit_item' => 'ویرایش تور',
            'new_item' => 'تور جدید',
            'view' => 'نمایش',
            'view_item' => 'نمایش',
            'search_items' => 'جستجوی تور',
            'not_found' => 'تور وجود ندارد.',
            'not_found_in_trash' => 'زباله خالی است.',
            'parent' => 'تور والد',
        ),
        'menu_icon' => 'dashicons-admin-site-alt'
    ));
}

/*********************************************** Register Taxonomy ***********************************************/
add_action('init', 'site_register_taxonomy');
function site_register_taxonomy()
{
    register_taxonomy(
        'destination',
        array('tour'),
        array(
            'labels' => array(
                'name'              => 'مقصد',
                'all_items'         => 'همه انواع مقاصد',
                'edit_item'         => 'ویرایش مقصد',
                'update_item'       => 'آپدیت مقصد',
                'add_new_item'      => 'اضافه کردن مقصد جدید',
            ),
            'sort' => true,
            'args' => array('orderby' => 'term_order'),
            'rewrite' => array('slug' => 'tour', 'with_front' => false,'hierarchical' => true,),
            'show_admin_column' => true,
            'show_in_rest' => false,
            'hierarchical' => true,
        )
    );
}

I want this URL structure for taxonomy and single posts:

taxonomy: site/tour/parent-tax/child-tax

post: site/tour/parent-tax/child-tax/single-post-url

now I make taxonomy structure but it gets 404 error and I don't know how to make single post url structre.

Does anyone have a solution for this?

Post a comment

comment list (0)

  1. No comments so far