PHP code example of humanmade / wp-term-images
1. Go to this page and download the library: Download humanmade/wp-term-images 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/ */
humanmade / wp-term-images example snippets
// image id is stored as term meta
$image_id = get_term_meta( 7, 'image', true );
// image data stored in array, second argument is which image size to retrieve
$image_data = wp_get_attachment_image_src( $image_id, 'full' );
// image url is the first item in the array (aka 0)
$image = $image_data[0];
if ( ! empty( $image ) ) {
echo '<img src="' . esc_url( $image ) . '" />';
}