WordPress.org

Ready to get started?Download WordPress

Forums

Impossible to edit taxonomy from a custom post type (6 posts)

  1. metamorpher
    Member
    Posted 3 years ago #

    Hello all.

    I just started to have this issue when I updated to 3.1 from 3.0.1. I had some custom post types for a car dealer website. And as you may figured it out already, I used taxonomies (a.k.a. "Categories") to arrange the cars by Brand, Car Type, and just that. So, I created 2 kinds of custom taxonomies.

    It all went good and was already working in my sandbox, and later in the actual production server. But now, when I auto-updated (never will do it again. Lesson learned), the editing of the custom taxonomies thrown an error telling me at the very best Nelson-from-the-simpsons-style: "Cheatin', huh? ha ha", when I didn't even set up the capabilities. It was doing cool without the capabilities, so I though "well, maybe for security reasons, now WP wants me to set up the capabilities for sure". I did it, and tried all available, but nothing happens, and I still have the problem.

    I had to hack the wp-admin/edit-tags.php and comment the line of the function die();but I know this is foolish and I need a solution I can implement into the content folder, and not editing the core files.

    I don't think is my fault, since in 3.0.1 it just worked fine. And for the record, the categories from the "Posts" sections are just working fine. Kinda funny since they use the same edit-tags.php file to make the edition.

    Ok crew. Thanks in advance for the help. Will wait for answers. :)

  2. metamorpher
    Member
    Posted 3 years ago #

    Well, by checking the 3.0 version of the edit-tags.php and comparing it to the 3.1 version, I can show you the following:

    3.1 version

    /** WordPress Administration Bootstrap */
    require_once('./admin.php');
    $tax = get_taxonomy( $taxnow );
    if ( !current_user_can( $tax->cap->manage_terms ) )
    	wp_die( __( 'Cheatin’ uh?' ) );

    3.0 version

    /** WordPress Administration Bootstrap */
    require_once('./admin.php');
    
    wp_reset_vars( array('action', 'tag', 'taxonomy', 'post_type') );
    
    if ( empty($taxonomy) )
    	$taxonomy = 'post_tag';
    
    if ( !taxonomy_exists($taxonomy) )
    	wp_die(__('Invalid taxonomy'));
    
    $tax = get_taxonomy($taxonomy);

    You do the math :)

  3. madpress
    Member
    Posted 3 years ago #

    Your problem is caused by a capital letter in your taxonomy name, you should have 'categories' instead of 'Categories'

  4. metamorpher
    Member
    Posted 3 years ago #

    don't think so... 'cause I went to the edit-tags.php and echoed the $taxnow var, and WP already uncapitalized the name and removed the space... Long story short: It doesn't matter the name syntax, 'cause the system adapts it.

    At the same time, I also use the function get_taxonomy() in my functions.php file, and I'm using it with capital letters and spaces, but I can still get the thing to work without problems.

  5. JohnnyPea
    Member
    Posted 2 years ago #

    Did you remove or somehow change the default taxonomy "post_tag"? If you set no capabilities it is probably checking for the same capabilities as for "post_tag" taxonomy so the problem could be there.

    I had the similar issue when I removed "post_tag" taxonomy using this portion of code hooked to the "init" hook:

    global $wp_taxonomies;
    	    $taxonomy = 'post_tag';
    	    if ( taxonomy_exists( $taxonomy))
    	        unset( $wp_taxonomies[$taxonomy]);

    I had to change this to not check the "post_tag" but "category" taxonomy:

    function pp_taxnow() {
    	global $taxnow;
    	if ( $taxnow == 'post_tag' )
    			$taxnow = 'category';
    }
    add_action('load-edit-tags.php', 'pp_taxnow');
  6. metamorpher
    Member
    Posted 2 years ago #

    well I "solved" it long before... sorry for not replying this on time, but madpress was right... you better use single names for the taxonomies before sinking in a glass of water like I did.

    just used underlines to separate names and it did the difference... thanks for your time guys!!

Topic Closed

This topic has been closed to new replies.

About this Topic