<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
G:\xampp\htdocs\wordpress4\wp-content\themes\shopping\functions.php
function register_cpt_music_review() {
$labels = array(
'name' => _x( 'Music Reviews', 'music_review' ),
'singular_name' => _x( 'Music Review', 'music_review' ),
'add_new' => _x( 'Add New', 'music_review' ),
'add_new_item' => _x( 'Add New Music Review', 'music_review' ),
'edit_item' => _x( 'Edit Music Review', 'music_review' ),
'new_item' => _x( 'New Music Review', 'music_review' ),
'view_item' => _x( 'View Music Review', 'music_review' ),
'search_items' => _x( 'Search Music Reviews', 'music_review' ),
'not_found' => _x( 'No music reviews found', 'music_review' ),
'not_found_in_trash' => _x( 'No music reviews found in Trash', 'music_review' ),
'parent_item_colon' => _x( 'Parent Music Review:', 'music_review' ),
'menu_name' => _x( 'Music Reviews', 'music_review' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'description' => 'Music reviews filterable by genre',
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes' ),
'taxonomies' => array( 'genres' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-format-audio',
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post'
);
register_post_type( 'music_review', $args );
}
add_action( 'init', 'register_cpt_music_review' );
function genres_taxonomy() {
register_taxonomy(
'genres',
'music_review',
array(
'hierarchical' => true,
'label' => 'Genres',
'query_var' => true,
'rewrite' => array(
'slug' => 'genre',
'with_front' => false
)
)
);
}
add_action( 'init', 'genres_taxonomy');
G:\xampp\htdocs\wordpress4\wp-content\plugins\review.php
<?php
/**
* Plugin Name: My Plugin Name
* Plugin URI: http://mypluginuri.com/
* Description: A brief description about your plugin.
* Version: 1.0 or whatever version of the plugin (pretty self explanatory)
* Author: Plugin Author's Name
* Author URI: Author's website
* License: A "Slug" license name e.g. GPL12
*/
G:\xampp\htdocs\wordpress4\wp-content\themes\shopping\index.php
<?php
$args = array(
'hierarchical' => true,
'rewrite' => array(
'slug' => 'genre',
'with_front' => false
)
);
$cats = get_categories($args);
foreach($cats as $cat) {
?>
<a href="<?php echo get_category_link( $cat->term_id ) ?>">
<?php echo $cat->name; ?>
</a>
<?php
}
?>