Skip to main content

Add Category Button Not Working Correctly

So, I have created a custom post type with custom taxonomy. Everything looks good and works, EXCEPT when I am creating a post and add a new category nothing happens. If I update the post then the category will show up. My code is below:

add_action( 'init', 'cut_files_custom_post_type' );
    function cut_files_custom_post_type() {

    $cut_file_labels = array(
        'name'               => _x( 'Cut Files', 'post type general name' ),
        'singular_name'      => _x( 'Cut File', 'post type singular name' ),
        'add_new'            => _x( 'Add Cut File', 'table' ),
        'add_new_item'       => __( 'Add New Cut File' ),
        'edit_item'          => __( 'Edit Cut File' ),
        'new_item'           => __( 'New Cut File' ),
        'all_items'          => __( 'All Cut Files' ),
        'view_item'          => __( 'View Cut File' ),
        'search_items'       => __( 'Search Cut Files' ),
        'not_found'          => __( 'No Cut Files found' ),
        'not_found_in_trash' => __( 'No Cut Files found in the Trash' ), 
        'menu_name'          => 'Cut Files'
    );

        $args= array(
            'public' => true,
            'labels' => $cut_file_labels,
            'menu_icon' => 'dashicons-images-alt2',
            'menu_position' => 20,
            'taxonomies' => array( 'cut_file_category', 'cut_file_tag' ),
            'has_archive' => true,
            'show_in_rest' => false,
            'hierarchical' => true,
            'supports' => array( 'title', 'revisions' )
        );

    register_post_type( 'cut_files', $args);
}
add_action( 'init', 'aic_custom_taxonomies', 0 );
    function aic_custom_taxonomies(){
        // Cut File Categories

        $cut_file_tax_labels = array(
            'name'              => _x( 'Cut File Categories', 'taxonomy general name' ),
            'singular_name'     => _x( 'Cut File Category', 'taxonomy singular name' ),
            'search_items'      => __( 'Search Cut File Categories' ),
            'all_items'         => __( 'All Cut File Categories' ),
            'parent_item'       => __( 'Parent Cut File Category' ),
            'parent_item_colon' => __( 'Parent Cut File Category:' ),
            'edit_item'         => __( 'Edit Cut File Category' ), 
            'update_item'       => __( 'Update Cut File Category' ),
            'add_new_item'      => __( 'Add New Cut File Category' ),
            'new_item_name'     => __( 'New Cut File Category' ),
            'menu_name'         => __( 'Cut File Categories' )
        );
        $args = array(
            'labels' => $cut_file_tax_labels,
            'hierarchical' => true,
            'query_var'     => true,  
            'rewrite'       => true,
            'show_in_rest' => true
        );

        register_taxonomy( 'cut_file_category', 'cut_file_items', $args );

    // Cut File Tags

        $cut_file_tax_labels = array(
            'name'              => _x( 'Cut File Tags', 'taxonomy general name' ),
            'singular_name'     => _x( 'Cut File Tag', 'taxonomy singular name' ),
            'search_items'      => __( 'Search Cut File Tags' ),
            'all_items'         => __( 'All Cut File Tags' ),
            'parent_item'       => __( 'Parent Cut File Tag' ),
            'parent_item_colon' => __( 'Parent Cut File Tag:' ),
            'edit_item'         => __( 'Edit Cut File Tag' ), 
            'update_item'       => __( 'Update Cut File Tag' ),
            'add_new_item'      => __( 'Add New Cut File Tag' ),
            'new_item_name'     => __( 'New Cut File Tag' ),
            'menu_name'         => __( 'Cut File Tags' )
        );
        $args = array(
            'labels' => $cut_file_tax_labels,
            'hierarchical' => false,
            'show_in_rest' => true
        );

        register_taxonomy( 'cut_file_tag', 'cut_file_items', $args );
}

When I look at the console for errors, I get this:

Uncaught TypeError: Cannot read properties of undefined (reading 'responses')
    at Object.catAddAfter [as addAfter] (post.js?ver=5.8.1:647)
    at Object.settings.complete (wp-lists.js?ver=5.8.1:385)
    at fire (jquery.js?ver=3.6.0:3500)
    at Object.fireWith (jquery.js?ver=3.6.0:3630)
    at done (jquery.js?ver=3.6.0:9811)
    at XMLHttpRequest.<anonymous> (jquery.js?ver=3.6.0:10057)

It is in the post.js file in wp-admin.

Any help on where I'm going wrong would be greatly appreciated.



source https://stackoverflow.com/questions/69728723/add-category-button-not-working-correctly

Comments

Popular posts from this blog

Where and how is this Laravel kernel constructor called? [closed]

Where and how is this Laravel kernel constructor called? public fucntion __construct(Application $app, $Router $roouter) { } I have read the documentation and some online tutorial but I can find any clear explanation. I am learning Laravel and I am wondering where does this kernel constructor receives its arguments from. "POSTMOTERM" CLARIFICATION: Here is more clarity.I have checked the boostrap/app.php and it is only used for boostrapping the interfaces into the container class. What is not clear to me is where and how the Kernel class is instatiated and the arguments passed to the object calling the constructor.Something similar to; obj = new kernel(arg1,arg2) or, is the framework using some magic functions somewhere? Special gratitude to those who burn their eyeballs and brain cells on this trivia before it goes into a full blown menopause alias "MARKED AS DUPLICATE". To some of the itchy-finger keyboard warriors, a.k.a The mods,because I believe in th...

Why is my reports service not connecting?

I am trying to pull some data from a Postgres database using Node.js and node-postures but I can't figure out why my service isn't connecting. my routes/index.js file: const express = require('express'); const router = express.Router(); const ordersCountController = require('../controllers/ordersCountController'); const ordersController = require('../controllers/ordersController'); const weeklyReportsController = require('../controllers/weeklyReportsController'); router.get('/orders_count', ordersCountController); router.get('/orders', ordersController); router.get('/weekly_reports', weeklyReportsController); module.exports = router; My controllers/weeklyReportsController.js file: const weeklyReportsService = require('../services/weeklyReportsService'); const weeklyReportsController = async (req, res) => { try { const data = await weeklyReportsService; res.json({data}) console...

Confusion between commands.Bot and discord.Client | Which one should I use?

Whenever you look at YouTube tutorials or code from this website there is a real variation. Some developers use client = discord.Client(intents=intents) while the others use bot = commands.Bot(command_prefix="something", intents=intents) . Now I know slightly about the difference but I get errors from different places from my code when I use either of them and its confusing. Especially since there has a few changes over the years in discord.py it is hard to find the real difference. I tried sticking to discord.Client then I found that there are more features in commands.Bot . Then I found errors when using commands.Bot . An example of this is: When I try to use commands.Bot client = commands.Bot(command_prefix=">",intents=intents) async def load(): for filename in os.listdir("./Cogs"): if filename.endswith(".py"): client.load_extension(f"Cogs.{filename[:-3]}") The above doesnt giveany response from my Cogs ...