Cómo agregar Entradas Relacionadas sin usar un Plugin

  • Autor Autor Usuario eliminado 17275
  • Fecha de inicio Fecha de inicio
U

Usuario eliminado 17275

Hola betas,

¿Alguien sabe como se hace para poner un "Entradas Relacionadas" sin necesidad de plugin?

Gracias
 
Hola aquí hice uno:
Agregas la función en functions.php.

HTML:
<?php function ZineyRelatedPosts($titulo,$post_ID){ 
   $max_links = 5; //Máximo de entradas a mostrar
   $i=0;   
   $tags = wp_get_post_tags($post_ID);  
    if($tags)    {        
       $first_tag = $tags[0]->term_id;      
      $args=array(  'tag__in' => array($first_tag),      
      'post__not_in' => array($post_ID),      
      'showposts'=> ($max_links),    
      'caller_get_posts'=>1        );    

      $consulta = new WP_Query($args);     
     if( $consulta->have_posts() ) {       
       echo $titulo.'<ul class="ZineyRelatedPosts">';     
       while ($consulta->have_posts()) : $consulta->the_post();  
              if($i<$max_links){         
                 echo '<li><a href="'.get_permalink().'" title="'.get_the_title().'">'.get_the_title().'</a></li>';    
               $i++;               
     }           
    endwhile;                      
  echo '</ul>';        
  }   
 }  
 wp_reset_query();
 }
?>

Luego en cualquier parte de tu single lo llamas asi:

PHP:
<?php ZineyRelatedPosts('<h3>Entradas relacionadas: </h3>',get_the_ID()) ?>

Aquí hay mas info:
http://www.tutsnt.com/tutoriales/wordpress/entradas-relacionadas-sin-plugin-wordpress/

 
Última edición:
Genial éste me fue muy util 😀
 
Atrás
Arriba