Wordpress Plugins UKM Custom Texonomy

By ukmodak | March 31st 2024 10:38:39 AM | viewed 1009 times

Create a file in the location \wp-content\plugins\ukm_custom_texonomy\ukm_custom_texonomy.php

<?php

/*
Plugin Name: ukm_custom_texonomy
Description: Add post types for movies and movie reviews
Author: Liam Carberry
*/

add_action( 'init', 'prowp_define_product_type_taxonomy',0 );
function prowp_define_product_type_taxonomy() {

    $labels = array(
        'name' => 'UKM Category',
        'singular_name' => 'UKM Category',
        'search_items' => 'Search Types',
        'all_items' => 'All Types',
        'parent_item' => 'Parent Type',
        'parent_item_colon' => 'Parent Type:', 
		'edit_item' => 'Edit Type',
        'update_item' => 'Update Type',
        'add_new_item' => 'Add New Type',
        'new_item_name' => 'New Type Name',
        'menu_name' => 'UKM Category'
    );
    $args = array( 
        'labels' => $labels, 
        'hierarchical' => true, 
        'public' => true,
        'show_ui' => true,
        'sort' => true,
        'query_var' => true,  
        'args' => array('orderby' => 'term_order'),
        'rewrite' => array('slug' => 'ukm_texonomy', 'with_front' => false)
          
    ); 
    //register_taxonomy( 'type', 'products', array( 'hierarchical' => true,'label' => 'Type', 'query_var' => true, 'rewrite' => true ) );
	register_taxonomy( 'ukm_custom_texonomy', 'village', $args);
}
?>
 

To view the texonomy page :

Create a file in the location \wp-content\themes\ukmtheme\taxonomy-ukm_custom_texonomy.php and the following code

 <?php

/**
 * The main template file
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * e.g., it puts together the home page when no home.php file exists.
 *
 * Learn more: {@link https://codex.wordpress.org/Template_Hierarchy}
 *
 * @package WordPress
 * @subpackage Twenty_Fifteen
 * @since Twenty Fifteen 1.0
 */

get_header(); ?>

	 <div class="workingArea bg">
        <div class="contentBg fullwidth">
            <div class="col-xs-12 col-sm-9 col-md-9 col-lg-9 paddingLeftzero contentAreaMediaWithMaxmin360  bg clrRight">
                <div class="fullwidth contentBg contentMinHeight">
                  <div class='content_padding'>	
 <?php
  $category_list = wp_list_categories( array(
  'taxonomy' => 'ukm_custom_texonomy',
  'orderby' => 'name',
  'show_count' => 0,
  'pad_counts' => 0,
  'hierarchical' => 1,
  'echo' => 0,
  'title_li' => 'Category'
) );

// Make sure there are terms with articles
if ( $category_list )
  echo '<ul class="locations-list">' . $category_list . '</ul>'; 
?>				  
                  <ul class="plist">
			         <?php while(have_posts()): the_post();?>
			        <li>
                           <div class="title"><a href="<?php the_permalink();?>"><?php the_title() ?></a></div>										
							<div class="content"><?php the_content(); ?></div>
			         </li>
			        <?php endwhile;?> 
					 <?php
					   global $wpdb;
					   $results = $wpdb->get_results( 'SELECT a.name FROM wp_terms a,wp_term_taxonomy b,wp_term_relationships c WHERE a.term_id=b.term_id and b.term_taxonomy_id= c.term_taxonomy_id and c.object_id ='.get_the_ID().'');
					   //print_r($results);							      
				     ?>					
			</ul> 	
                 </div>
               </div>
            </div>
        </div>
    </div>
    
<?php get_footer(); ?>
 

bONEandALL
Visitor

Total : 27273

Today :9

Today Visit Country :

  • United States
  • Sweden
  • Singapore
  • Russia