Untitled

mail@pastecode.io avatar
unknown
php
3 years ago
608 B
6
Indexable
Never
 function acf_relacionadas( $content ) {
	  
	  
	  $posts = get_field('relacionadas');
 
      if($posts == ""){
       
		  $ad_code = "";
		  
	  } else {
		  
		   foreach( $posts as $post ): 
		  
		   setup_postdata($post); ?>
		  
		  <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>

		<?php endforeach;
		  
	  }

    

    if ( is_single() && ! is_admin() ) {
      if(has_tag('norelated')) {  } else {
       
          return prefix_insert_after_paragraph( $ad_code, 3, $content );
        
      }
    }

    return $content;
  }


  add_filter( 'the_content', 'acf_relacionadas' );