• Resolved Jojogali

    (@jojogali)


    Hi! I’ve used your plugin to add a custom taxonomy to my custom post type, but now I’m having some difficulties adding a column to display said taxonomy’s value.

    Can you please help me? I’ve marked the “show_admin_column” but it doesn’t work.

    What I think would help was to know where the taxonomy is added by the plugin, in which files, so I can see the code used. Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Beda

    (@bedas)

    show_admin_column is all you need.

    THe taxonomy is added in the Database – it’s not PHP code.

    Please try the basic debug steps (no other plugins, a new taxonomy, another theme) to check that you are not dealing with a compatibility issue.

    If not, please report this in the Support Forum so we can grab a site’s snapshot and analyse it better.

    It’s free.

    • This reply was modified 6 years, 8 months ago by Beda.
    Thread Starter Jojogali

    (@jojogali)

    I can’t seem to register for support, but I can provide you with the code currently active to organize admin columns:

    /**
    * Adiciona colunas ao admin Imóvel
    *
    ***/
    add_filter( 'manage_edit-imovel_columns', 'ssys_edit_imovel_columns' ) ;
    function ssys_edit_imovel_columns( $columns ) {
    
    	$columns = array(
    		'cb' => '<input type="checkbox" />',
    		'ref' => __( 'Ref.' ),
    		'imagem' => __('Imagem'),
    		'title' => __( 'Imóvel' ),
    		'destaque' => __('<span class="dashicons dashicons-star-half"></span>'), 
    		'valor' => __( 'Valor' ),
    		'angariacao' => __( 'Nº Ang.' ),
    		'author' => __( 'Comercial' ),
    		'date' => __( 'Date' )
    	);
    
    	return $columns;
    }
    
    add_action( 'manage_imovel_posts_custom_column', 'ssys_manage_imovel_columns', 10, 2 );
    function ssys_manage_imovel_columns( $column, $post_id ) {
    	global $post;
    
    	switch( $column ) {
    
    		case 'ref' :
    			
    			echo  get_the_ID();
    			
    			break;
    
    		case 'imagem' :
    
    			echo get_the_post_thumbnail( $post_id, array( 100, 100) );
    
    			break;
    
    		case 'imovel' :
    
    			break;
    
    		case 'valor' :
    
    			/* Get the post meta. */
    			$venda = get_post_meta( $post_id, '_ssys_valor_venda_imovel', true );
    			$arrendamento = get_post_meta( $post_id, '_ssys_valor_arrendamento_imovel', true );
    			$trespasse = get_post_meta( $post_id, '_ssys_valor_trespasse_imovel', true );
    
    			if( $venda != '0,00' )
    				echo '<strong> Venda:</strong> '. $venda;
    			if( $arrendamento != '0,00' )
    				echo '<strong> Arrendamento:</strong>'. $arrendamento;
    			if( $trespasse != '0,00' )
    				echo '<strong> Trespasse: </strong>'. $trespasse;
    
    			break;
    			
    		case 'destaque' :
    
    			$destaque = get_post_meta( $post_id, '_ssys_destaque_imovel', true );
    			if($destaque){
    				echo '<span data-id="'. $post_id .'" data-action="unset" class="dashicons dashicons-star-filled"></span>';
    			}else{
    				echo '<span data-id="'. $post_id .'" data-action="set" class="dashicons dashicons-star-empty"></span>';
    			}
    
    			break;
    
    		case 'angariacao':
    
    			$refImovel = get_post_meta( get_the_ID(), '_ssys_num_angariacao_imovel', true );
    			echo $refImovel;
    
    			break;
    
    		/* Just break out of the switch statement for everything else. */
    		default :
    			break;
    
    	}
    }
    
    function column_title($item){
        
        //Build row actions
        $actions = array(
            'edit'      => sprintf('<a href="/wp-admin/post.php?post=%s&action=%s&imovel=%s">Edit</a>',$item->ID,'edit',$item->ID),
        );
        
        if($this->post_type == 'interacao'){
    
        	
        	if( get_post_meta( $item->ID, '_ssys_privada_interacao', true ) == 'on')
        		$interacao_privada = '<strong>Privado </strong>';
    
        	//Return the title contents
            return sprintf('%1$s %2$s %3$s',
            	/*$1%s*/ $interacao_privada,
                /*$2%s*/ $item->post_title,
                /*$3%s*/ $this->row_actions($actions)
            );
    
        }else{
    
        	//Return the title contents
            return sprintf('%1$s %2$s',
                /*$1%s*/ $item->post_title,
                /*$2%s*/ $this->row_actions($actions)
            );
    
        }
    
        
    }

    Is it possible I have to add it there? This was not developed by my, so I wouldn’t know how to properly do so.

    Plugin Support Beda

    (@bedas)

    As said, you do not need Custom Code to have that column appearing.
    Most likely your Custom Code is the exact issue it does not work.

    You can control that it works great on a WordPress vanilla install using Types only and the setting mentioned (show_admin_column).

    We can unfortunately not assist Custom Coding, but perhaps other users here can.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Taxonomy Admin Column’ is closed to new replies.