1

我有一个分类法,我创建如下:

function understrap_custom_taxonomies() {
    $post_types_index = array('cs_publications', 'cs_projects');
    $taxs = array(
            'cs_themes' => array(
                'menu_title'   => 'Themes',
                'plural'       => 'Themes',
                'singular'     => 'Theme',
                'hierarchical' => true,
                'slug'         => 'theme',
                'post_type'    => array( 'post', 'cs_publications', 'cs_projects', 'cs_events')
            )
        );

    foreach( $taxs as $tax => $args ) {
        $labels = array(
            'name'                => _x( $args['plural'], 'taxonomy general name' ),
            'singular_name'       => _x( $args['singular'], 'taxonomy singular name' ),
            'search_items'        => __( 'Search '.$args['plural'] ),
            'all_items'           => __( 'All '.$args['plural'] ),
            'parent_item'         => __( 'Parent '.$args['plural'] ),
            'parent_item_colon'   => __( 'Parent '.$args['singular'].':' ),
            'edit_item'           => __( 'Edit '.$args['singular'] ), 
            'update_item'         => __( 'Update '.$args['singular'] ),
            'add_new_item'        => __( 'Add New '.$args['singular'] ),
            'new_item_name'       => __( 'New '.$args['singular'].' Name' ),
            'menu_name'           => __( $args['menu_title'] )
        );  
        $tax_args = array(
            'hierarchical'        => $args['hierarchical'],
            'labels'              => $labels,
            'public'              => true,
            'show_ui'             => true,
            'show_admin_column'   => true,
            'show_in_nav_menus'   => true,
            'show_tagcloud'       => true,
            'show_in_rest'        => true,
            'with_front'          => false,
            'rewrite'             => array( 'slug' => $args['slug'] ),
        );
        register_taxonomy( $tax, $args['post_type'], $tax_args );
    }
}
add_action('init', 'understrap_custom_taxonomies');

我现在正在尝试使用自定义字段元素获取“cs_themes”的值以显示在 WP Bakery 网格中:

WP面包店截图

然而,无论我输入“cs_themes”、“taxonomy_cs_themes”还是任何其他逻辑组合,它似乎都没有通过这些值。任何建议将不胜感激。

4

0 回答 0