• 1.
    add_shortcode('display_post_tags', 'post_tags');
  • 2.
    function post_tags () {
  • 3.
     
  • 4.
    global $post;
  • 5.
    $terms = get_the_terms( get_the_ID(), 'category');
  • 6.
    $post_tags = get_the_tags($post->ID);	
  • 7.
    										
  • 8.
    ob_start(); ?>
  • 9.
    <div class="tags">
  • 10.
    	<span class="post-cat">
  • 11.
    <?php
  • 12.
    	if( !empty($terms) ) {
  • 13.
    		$term = array_pop($terms);
  • 14.
    		//This field gives us the custom image related to the category post
  • 15.
    		$catsvg = get_field('postcat_featured', $term );
  • 16.
    		echo $catsvg;
  • 17.
    	}
  • 18.
    	echo get_the_category( $post->ID )[0]->name; 
  • 19.
    ?>
  • 20.
    	</span>	
  • 21.
    <?php if (! empty( $post_tags )) { ?>
  • 22.
    	<span class="post-tag">
  • 23.
    		<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><path d="M168.3 499.2C116.1 435 0 279.4 0 192C0 85.96 85.96 0 192 0C298 0 384 85.96 384 192C384 279.4 267 435 215.7 499.2C203.4 514.5 180.6 514.5 168.3 499.2H168.3zM192 256C227.3 256 256 227.3 256 192C256 156.7 227.3 128 192 128C156.7 128 128 156.7 128 192C128 227.3 156.7 256 192 256z"/></svg>
  • 24.
    			<?php echo $post_tags[0]->name;  ?>
  • 25.
    	</span>
  • 26.
    		<?php  } ?>
  • 27.
    		
  • 28.
    <?php if (get_field('post_proximity_cpg')) { ?>
  • 29.
    	<span class="proximity">
  • 30.
    		<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M256 96C256 113.7 270.3 128 288 128C305.7 128 320 113.7 320 96V32H394.8C421.9 32 446 49.08 455.1 74.63L572.9 407.2C574.9 413 576 419.2 576 425.4C576 455.5 551.5 480 521.4 480H320V416C320 398.3 305.7 384 288 384C270.3 384 256 398.3 256 416V480H54.61C24.45 480 0 455.5 0 425.4C0 419.2 1.06 413 3.133 407.2L120.9 74.63C129.1 49.08 154.1 32 181.2 32H255.1L256 96zM320 224C320 206.3 305.7 192 288 192C270.3 192 256 206.3 256 224V288C256 305.7 270.3 320 288 320C305.7 320 320 305.7 320 288V224z"/></svg>
  • 31.
    <?php echo get_field('post_proximity_cpg') ?><?php esc_html_e( 'km', 'psj_global' ); ?>
  • 32.
    	</span>
  • 33.
    		<?php } ?>
  • 34.
    </div>
  • 35.
    <?php	
  • 36.
    	return ob_get_clean();
  • 37.
    }
add_shortcode('display_post_tags', 'post_tags'); function post_tags () { global $post; $terms = get_the_terms( get_the_ID(), 'category'); $post_tags = get_the_tags($post->ID); ob_start(); ?> <div class="tags"> <span class="post-cat"> <?php if( !empty($terms) ) { $term = array_pop($terms); //This field gives us the custom image related to the category post $catsvg = get_field('postcat_featured', $term ); echo $catsvg; } echo get_the_category( $post->ID )[0]->name; ?> </span> <?php if (! empty( $post_tags )) { ?> <span class="post-tag"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><path d="M168.3 499.2C116.1 435 0 279.4 0 192C0 85.96 85.96 0 192 0C298 0 384 85.96 384 192C384 279.4 267 435 215.7 499.2C203.4 514.5 180.6 514.5 168.3 499.2H168.3zM192 256C227.3 256 256 227.3 256 192C256 156.7 227.3 128 192 128C156.7 128 128 156.7 128 192C128 227.3 156.7 256 192 256z"/></svg> <?php echo $post_tags[0]->name; ?> </span> <?php } ?> <?php if (get_field('post_proximity_cpg')) { ?> <span class="proximity"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M256 96C256 113.7 270.3 128 288 128C305.7 128 320 113.7 320 96V32H394.8C421.9 32 446 49.08 455.1 74.63L572.9 407.2C574.9 413 576 419.2 576 425.4C576 455.5 551.5 480 521.4 480H320V416C320 398.3 305.7 384 288 384C270.3 384 256 398.3 256 416V480H54.61C24.45 480 0 455.5 0 425.4C0 419.2 1.06 413 3.133 407.2L120.9 74.63C129.1 49.08 154.1 32 181.2 32H255.1L256 96zM320 224C320 206.3 305.7 192 288 192C270.3 192 256 206.3 256 224V288C256 305.7 270.3 320 288 320C305.7 320 320 305.7 320 288V224z"/></svg> <?php echo get_field('post_proximity_cpg') ?><?php esc_html_e( 'km', 'psj_global' ); ?> </span> <?php } ?> </div> <?php return ob_get_clean(); }

Copy Code to Clipboard Raw

Sign-in or Create a Free Account.

Snippi uses Twitter or Facebook to register and create accounts. Registration will enable you to keep track of your snippets. We never spam your timeline or wall. Ever.

Sign-in with Facebook Sign-in with Twitter