Advise on Custom Taxonomies and Structure

I am building a sporting website with the following structure

Categories

  • Events (Like Superbowl 2017)
  • Deals (Posts like “Fly to USA to Watch Superbowl for $1000” etc)
  • News (Posts like “Sanfransisco make superbowl 2016”)
  • Tours (Posts Like “Group tours to USA for Superbowl”)

Now I am struggling with the taxonomies.
I was thinking of using the following

  • City (This would be sity of the sporting event eg Houston)
  • Sport (American Football, Cricket, Soccer)
  • League (NFL, NBA etc)
  • Venue (NRG Stadium)
  • Team (San Fransico 49ers, Barcelona, Manceher United ETC.
  • Provider (Jogns Travel Tours)

So if I was doing a post about the Superbowl it would be an event that has the relevant taxonomies linked to it. Then I could post about a group tour to England to watch premier league, and it would be a Tour, with League, Venue etc added.

What I also want to do is add information about the team, stadium etc. How would I be best to do that? Could I use custom fields for each taxonomy, eg Team would have date founded and history. Venue would have capacity etc.

What do you think? How else could I structure the site to get what I need?

Thanks
Richard

Answer

That’s how you resister taxonomy. This will add author as taxonomy

<?php 
/**
 * @uses  Register Book Author Taxonomy
 * @uses  Adds query vars
 * @author Nirpendra Patel
 * @return void
 **/
function reg_tax_author() {

    $authors = array(
        'name'                  => _x( 'Authors', 'Taxonomy plural name', 'b_thebookstore' ),
        'singular_name'         => _x( 'Author', 'Taxonomy singular name', 'b_thebookstore' ),
        'search_items'          => __( 'Search Authors', 'b_thebookstore' ),
        'popular_items'         => __( 'Popular Authors', 'b_thebookstore' ),
        'all_items'             => __( 'All Authors', 'b_thebookstore' ),
        'parent_item'           => __( 'Parent Author', 'b_thebookstore' ),
        'parent_item_colon'     => __( 'Parent Author:', 'b_thebookstore' ),
        'edit_item'             => __( 'Edit Author', 'b_thebookstore' ),
        'update_item'           => __( 'Update Author', 'b_thebookstore' ),
        'add_new_item'          => __( 'Add New Author', 'b_thebookstore' ),
        'new_item_name'         => __( 'New Author Name', 'b_thebookstore' ),
        'add_or_remove_items'   => __( 'Add or remove Authors', 'b_thebookstore' ),
        'choose_from_most_used' => __( 'Choose from most used Authors', 'b_thebookstore' ),
        'menu_name'             => __( 'Authors', 'b_thebookstore' ),
    );

    $args = array(
        'labels'            => $authors,
        'public'            => true,
        'show_in_nav_menus' => true,
        'show_admin_column' => true,
        'hierarchical'      => true,
        'show_tagcloud'     => true,
        'show_ui'           => true,
        'query_var'         => true,
        'rewrite'           => true,
        'query_var'         => true,
        'capabilities'      => array(),
    );

    register_taxonomy( 'author', array( 'post' ), $args );
}
add_action( 'init', 'reg_tax_author' );
    ?>

here in

register_taxonomy( 'author', array( 'post' ), $args );

change ‘post’ to whatever custom post type or let it be as it is to use taxonomy on posts. That’s all you need to register it. Put all in your functions.php

Attribution
Source : Link , Question Author : Richard Ascough , Answer Author : Nirpendra Patel

Leave a Comment