PHP code example of vektor-inc / vk-term-color

1. Go to this page and download the library: Download vektor-inc/vk-term-color library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vektor-inc / vk-term-color example snippets


use VektorInc\VK_Term_Color\VkTermColor;

// カラーピッカー使用時
$vk_term_color = VkTermColor::get_instance();
VkTermColor::init(); 


// 表示用のHTMLを取得する
$args = array(
	'outer_element'      => 'div',
	'outer_class'        => '',
	'single_element'     => '',
	'single_class'       => '',
	'single_inner_class' => 'btn btn-sm',
	'link'               => true,
	'color'              => true,
	'taxonomy'           => '', // 表示したいカスタム分類を指定 例) 'category' や 'post_tag'
	'gap'                => '0.5rem',
	'separator'          => '',
);
echo VkTermColor::get_post_terms_html( '', $args );

use VektorInc\VK_Term_Color\VkTermColor;

global $post;
$args = array(
	'taxonomy' => 'area', // 対象のタクソノミーを指定
);
if ( class_exists( VkTermColor::class ) && method_exists( VkTermColor::class, 'get_post_single_term_info' ) ) {
	$term_info = VkTermColor::get_post_single_term_info( $post, $args );
	echo '<pre style="text-align:left">';
	print_r( $term_info );
	echo '</pre>';
}