Advertisement
fauzanjeg

Add Tag from Article to Meta Tag

Jan 15th, 2021
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.34 KB | None | 0 0
  1. /* Add Tag from Article to Meta Tag */
  2. function add_tag_from_article() {
  3.     if ( is_singular() && is_single() ) {
  4.         global $post;
  5.         $tags=get_the_tags( $post->ID );
  6.         foreach ( $tags as $tag ) {
  7.             ?>
  8.             <meta content="<?php echo $tag->name ?>" property="og:tag" />
  9.             <?php
  10.         }
  11.     }
  12. }
  13.  
  14. add_action( 'wp_head', 'add_tag_from_article' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement