Forum Replies Created

Viewing 15 replies - 1 through 15 (of 29 total)
  • nice. would be better if use rewrite url also.

    can use code provided in this thread for temporary fix.

    Function Reference/register taxonomy

    try set your rewrite rule to false.

    'rewrite' => false,

    @decio

    try add this to your registered taxonomy.

    'taxonomies' => array('category','post_tag')

    it will use default category and tags taxonomies.

    Thread Starter Od3n

    (@od3n)

    ok figured it out.

    function has_product_tag( $product_tag, $_post = null ) {
    	if ( !empty( $product_tag ) )
    		return false;
    
    	if ( $_post )
    		$_post = get_post( $_post );
    	else
    		$_post =& $GLOBALS['post'];
    
    	if ( !$_post )
    		return false;
    
    	$r = is_object_in_term( $_post->ID, 'product_tag', $product_tag );
    
    	if ( is_wp_error( $r ) )
    		return false;
    
    	return $r;
    }
    <?php if(has_product_tag(null)) { ?>
    // some code here
    <?php } ?>
    Od3n

    (@od3n)

    nvmnd. get it done already.

    Od3n

    (@od3n)

    @c3mdigital got the work done already. see here many thanks for inspired me.

    Thread Starter Od3n

    (@od3n)

    get it done already. here my code. free to use 🙂

    @t31os_ very much thanks to you. managed to get it done with your help. really happy to share my code to whoever want to have custom categories and tags to be displayed like normal post list.

    function product_columns($posts_columns) {
    	$posts_columns = array();
    	$posts_columns['cb'] = '<input type="checkbox" />';
    	$posts_columns['title'] = _x('Title', 'column name');
    	$posts_columns['author'] = __('Author');
    	if ( empty($post_type) || is_object_in_taxonomy($post_type, 'category') )
    		$posts_columns['product_categories'] = __('Categories');
    	if ( empty($post_type) || is_object_in_taxonomy($post_type, 'post_tag') )
    		$posts_columns['product_tags'] = __('Tags');
    	$post_status = !empty($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'all';
    	if ( !in_array( $post_status, array('pending', 'draft', 'future') ) && ( empty($post_type) || post_type_supports($post_type, 'comments') ) )
    		$posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="' . esc_url( admin_url( 'images/comment-grey-bubble.png' ) ) . '" /></div>';
    	$posts_columns['date'] = __('Date');
    
    	return $posts_columns;
    }	
    
    function product_data_columns( $column_name) {
    		switch ($column_name) {
    		case 'product_categories':
    		$_taxonomy = 'product_category';
    		$categories = get_the_terms( $post_id, $_taxonomy );
    		if ( !empty( $categories ) ) {
    			$out = array();
    			foreach ( $categories as $c )
    				$out[] = "<a href='edit.php?product_category=$c->slug&post_type=product'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
    			echo join( ', ', $out );
    		}
    		else {
    			_e('Uncategorized');
    		}
    		break;
    
    		case 'product_tags':
    		$_taxonomy = 'product_tag';
    		$tags = get_the_terms( $post_id, $_taxonomy );
    		if ( !empty( $tags ) ) {
    			$out = array();
    			foreach ( $tags as $c )
    				$out[] = "<a href='edit.php?product_tag=$c->slug&post_type=product'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_type', 'display')) . "</a>";
    				echo join( ', ', $out );
    		}
    		else {
    			_e(' No Tags');
    		}
    		break;
    	}
    }
    add_filter( 'manage_product_posts_columns', 'product_columns' );
    add_action( 'manage_posts_custom_column', 'product_data_columns', 10, 2 );

    just like t31os_ code here, most of it i copied from template.php and make minor adjustment to reflect my custom taxonomies.

    Od3n

    (@od3n)

    @t31os_ very much thanks to you. managed to get it done with your help. really happy to share my code to whoever want to have custom categories and tags to be displayed like normal post list.

    function product_columns($posts_columns) {
    	$posts_columns = array();
    	$posts_columns['cb'] = '<input type="checkbox" />';
    	$posts_columns['title'] = _x('Title', 'column name');
    	$posts_columns['author'] = __('Author');
    	if ( empty($post_type) || is_object_in_taxonomy($post_type, 'category') )
    		$posts_columns['product_categories'] = __('Categories');
    	if ( empty($post_type) || is_object_in_taxonomy($post_type, 'post_tag') )
    		$posts_columns['product_tags'] = __('Tags');
    	$post_status = !empty($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'all';
    	if ( !in_array( $post_status, array('pending', 'draft', 'future') ) && ( empty($post_type) || post_type_supports($post_type, 'comments') ) )
    		$posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="' . esc_url( admin_url( 'images/comment-grey-bubble.png' ) ) . '" /></div>';
    	$posts_columns['date'] = __('Date');
    
    	return $posts_columns;
    }	
    
    function product_data_columns( $column_name) {
    		switch ($column_name) {
    		case 'product_categories':
    		$_taxonomy = 'product_category';
    		$categories = get_the_terms( $post_id, $_taxonomy );
    		if ( !empty( $categories ) ) {
    			$out = array();
    			foreach ( $categories as $c )
    				$out[] = "<a href='edit.php?product_category=$c->slug&post_type=product'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
    			echo join( ', ', $out );
    		}
    		else {
    			_e('Uncategorized');
    		}
    		break;
    
    		case 'product_tags':
    		$_taxonomy = 'product_tag';
    		$tags = get_the_terms( $post_id, $_taxonomy );
    		if ( !empty( $tags ) ) {
    			$out = array();
    			foreach ( $tags as $c )
    				$out[] = "<a href='edit.php?product_tag=$c->slug&post_type=product'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_type', 'display')) . "</a>";
    				echo join( ', ', $out );
    		}
    		else {
    			_e(' No Tags');
    		}
    		break;
    	}
    }
    add_filter( 'manage_product_posts_columns', 'product_columns' );
    add_action( 'manage_posts_custom_column', 'product_data_columns', 10, 2 );

    just like t31os_ code, most of it i copied from template.php and make minor adjustment to reflect my custom taxonomies.

    Od3n

    (@od3n)

    ok thanks. will try and update later.

    Od3n

    (@od3n)

    pages & categories are hierarchical.
    posts & tags are not hierarchical.

    means pages & categories can have parent, butposts & tags cant. UI will depends on the hierarchical.

    Od3n

    (@od3n)

    may be you could share some code here.

    Od3n

    (@od3n)

    how about to use custom categories and/or post tags ?

    Od3n

    (@od3n)

    @pmdci

    here the code i use.

    <?php if(is_singular('product')) { ?>
    		<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(Products) ) : ?>
    		<?php endif; ?>
    	<?php } else { ?>
    		<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
    		<?php endif; ?>
    	<?php } ?>

    before this i use is_single() && is_post_type($post_type) but they doesnt seems to work.

    Od3n

    (@od3n)

    i mean on your books list or edit page. admin menu just work fine.

    i want to display categories and tags like this :

    http://dl.dropbox.com/u/2317543/Screen%20shot%202010-06-08%20at%203.03.56%20AM.png

    they are missing here :

    http://dl.dropbox.com/u/2317543/Screen%20shot%202010-06-07%20at%202.54.14%20PM.png

Viewing 15 replies - 1 through 15 (of 29 total)