PHP code example of stuttter / wp-term-images
1. Go to this page and download the library: Download stuttter/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/ */
stuttter / 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 ) . '" />';
}