BuddyDev

Search

[Resolved] Buddyblog support

  • Participant
    Level: Guru
    Posts: 885
    Tosin on #46934

    Hi

    I created two new taxonomies (location) and (post type) using the code below. In the buddyblog form settings, options for (location) saved successfully but the changed options for (post type) is not saving.

     function create_post_type_taxonomy() {
      // Add new "Post Types" taxonomy to Posts
      register_taxonomy('Post Type', 'post', array(
        // Hierarchical taxonomy (like categories)
        'hierarchical' => true,
        // This array of options controls the labels displayed in the WordPress Admin UI
        'labels' => array(
          'name' => _x( 'Post Types', 'taxonomy general name' ),
          'singular_name' => _x( 'Post Type', 'taxonomy singular name' ),
          'search_items' =>  __( 'Search Post Types' ),
          'all_items' => __( 'All Post Types' ),
          'parent_item' => __( 'Parent Post Type' ),
          'parent_item_colon' => __( 'Parent Post Type:' ),
          'edit_item' => __( 'Edit Post Type' ),
          'update_item' => __( 'Update Post Type' ),
          'add_new_item' => __( 'Add New Post Type' ),
          'new_item_name' => __( 'New Post Type Name' ),
          'menu_name' => __( 'Post Types' ),
        ),
        // Control the slugs used for this taxonomy
        'rewrite' => array(
          'slug' => 'post-type', // This controls the base slug that will display before each term
          'with_front' => false, // Don't display the category base before "/Post Types/"
          'hierarchical' => true // This will allow URL's like "/Post Types/public/"
        ),
      ));
    }
    add_action( 'init', 'create_post_type_taxonomy', 0 ); 
  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #46941

    Hi Tosin,
    I am sorry about the issue.
    Please share the complete code for registering the taxonomies to help us understan dthe issue. You may post on pastebin and link us here.

    Thank you
    Brajesh

  • Participant
    Level: Guru
    Posts: 885
    Tosin on #46952

    This are the 2 codes below being used as two different plugins

    LOCATION TAXONOMY PLUGIN

     <?php
    /**
    Plugin Name: WP Taxonomy - Location
    Version: 1.0
    Author: WordPress
    Description: Craete a new location taxonomy to organise content
    */
    
    function create_post_location_taxonomy() {
      // Add new "Locations" taxonomy to Posts
      register_taxonomy('location', 'post', array(
        // Hierarchical taxonomy (like categories)
        'hierarchical' => true,
        // This array of options controls the labels displayed in the WordPress Admin UI
        'labels' => array(
          'name' => _x( 'Locations', 'taxonomy general name' ),
          'singular_name' => _x( 'Location', 'taxonomy singular name' ),
          'search_items' =>  __( 'Search Locations' ),
          'all_items' => __( 'All Locations' ),
          'parent_item' => __( 'Parent Location' ),
          'parent_item_colon' => __( 'Parent Location:' ),
          'edit_item' => __( 'Edit Location' ),
          'update_item' => __( 'Update Location' ),
          'add_new_item' => __( 'Add New Location' ),
          'new_item_name' => __( 'New Location Name' ),
          'menu_name' => __( 'Locations' ),
        ),
        // Control the slugs used for this taxonomy
        'rewrite' => array(
          'slug' => 'post-location', // This controls the base slug that will display before each term
          'with_front' => false, // Don't display the category base before "/locations/"
          'hierarchical' => true // This will allow URL's like "/locations/boston/cambridge/"
        ),
      ));
    }
    add_action( 'init', 'create_post_location_taxonomy', 0 ); 

    POST TYPE TAXONOMY PLUGIN

     <?php
    /**
    Plugin Name: WP Taxonomy - Post Type
    Version: 1.0
    Author: WordPress
    Description: Craete a new post type taxonomy to organise content
    */
    
    function create_post_type_taxonomy() {
      // Add new "Post Types" taxonomy to Posts
      register_taxonomy('Post Type', 'post', array(
        // Hierarchical taxonomy (like categories)
        'hierarchical' => true,
        // This array of options controls the labels displayed in the WordPress Admin UI
        'labels' => array(
          'name' => _x( 'Post Types', 'taxonomy general name' ),
          'singular_name' => _x( 'Post Type', 'taxonomy singular name' ),
          'search_items' =>  __( 'Search Post Types' ),
          'all_items' => __( 'All Post Types' ),
          'parent_item' => __( 'Parent Post Type' ),
          'parent_item_colon' => __( 'Parent Post Type:' ),
          'edit_item' => __( 'Edit Post Type' ),
          'update_item' => __( 'Update Post Type' ),
          'add_new_item' => __( 'Add New Post Type' ),
          'new_item_name' => __( 'New Post Type Name' ),
          'menu_name' => __( 'Post Types' ),
        ),
        // Control the slugs used for this taxonomy
        'rewrite' => array(
          'slug' => 'post-type', // This controls the base slug that will display before each term
          'with_front' => false, // Don't display the category base before "/Post Types/"
          'hierarchical' => true // This will allow URL's like "/Post Types/public/"
        ),
      ));
    }
    add_action( 'init', 'create_post_type_taxonomy', 0 ); 
  • Participant
    Level: Guru
    Posts: 885
    Tosin on #46953

    Hello the problem came from here

    register_taxonomy(‘Post Type’, ‘post’, array(

    it should be like this

    register_taxonomy(‘post_type’, ‘post’, array(

  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #46954

    You are quite right. Your code has space in taxonomy name which is not allowed by WordPress.

    Also, please avoid using ‘post_type’ as taxonomy name, It is a lot confusing and will cause you headaches in future maintenance.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: resolved