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

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...

How to show number of registered users in Laravel based on usertype?

i'm trying to display data from the database in the admin dashboard i used this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count(); echo $users; ?> and i have successfully get the correct data from the database but what if i want to display a specific data for example in this user table there is "usertype" that specify if the user is normal user or admin i want to user the same code above but to display a specific usertype i tried this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count()->WHERE usertype =admin; echo $users; ?> but it didn't work, what am i doing wrong? source https://stackoverflow.com/questions/68199726/how-to-show-number-of-registered-users-in-laravel-based-on-usertype

The number of nodes and edges I calculated manually and by a method provided by networkx library dont match

I am trying to analyse a graph using networkx library in Python. I have implemented a function that returns the nodes and edges of that graph. After that I counted the number of nodes and edges by implementing the len() function for nodes and edges, which gave me 17 for both nodes and edges. However, when I used the method graph.number_of_nodes() of networkx library it gave me 53. My code: import pandas as pd import networkx as nx import matplotlib.pyplot as plt header_list = ["a","b","w"] E =pd.read_csv("aves-barn-swallow-contact-network.edges",sep=" ",header= None,names=header_list) # print(E.head()) # prints first few rows of the csv file G = nx.from_pandas_edgelist(E,"a","b",["w"]) nx.draw(G) plt.show() class GraphAnalyse: #finding nodes and edges def nodeEdge(self,Graph): nodes = Graph.nodes() edges = Graph.edges() ...