Ver Mensaje Individual
  #8 (permalink)  
Antiguo 10/03/2013, 14:40
luchozero
 
Fecha de Ingreso: diciembre-2006
Mensajes: 384
Antigüedad: 17 años, 4 meses
Puntos: 5
Respuesta: Codigo en index no funciona en functions

Código:
function listar_aleatorio($total,$id=NULL,$tipo=1,$recortartitulo=100,$recortardescripcion=200){

	$listado='';

	$catid='';

	$upload_dir = wp_upload_dir();

	foreach((get_the_category($id)) as $category) { 

    $catid.=$category->cat_ID.','; 

	}

	$my_query2 = new WP_Query('posts_per_page='.$total.'&ignore_sticky_posts=1&orderby=rand&cat='.$catid);

	if ($my_query2->have_posts()) : while ($my_query2->have_posts()) : $my_query2->the_post();

		if(get_the_ID()==$id) continue;

if($tipo==1){

					$duracion = get_post_meta(get_the_ID(), 'duracion', true);

					$votos=get_post_meta(get_the_ID(), 'ratings_score', true);

					$pieces = explode("-", $votos);

					$votos=str_replace('-','',$votos);

$listado.='

                	<!--<post>-->

                	<li class="fx">

                    	<article>

                        	<header class="imgpst pore">

                            	<a href="'.get_permalink().'">

                                	<img src="'.mt_img(get_the_ID(),'thumbnail').'" alt="imagen video '.get_the_title().'"'; if (substr_count(mt_img(get_the_ID(),'thumbnail'), 'thumbnail') != 1) { $listado.='class="flipbook" data-max="'.get_post_meta(get_the_ID(),'thn',true).'" data-thumbnail="'.mt_img(get_the_ID()).'" data-path="'.$upload_dir['baseurl'].'/'.get_the_ID().'-{index}.jpg"'; } $listado.='>

                                    <span class="poab fx">';

									if(count($pieces)==2){ $listado.='<span class="vodo flor">'.$votos.' <i class="ico icovot"></i></span>'; }else{ $listado.='<span class="voup flor">'.$votos.'<i class="ico icovot"></i></span>'; }

									if($duracion!=''){ echo $duracion; }

									$listado.='</span>

                                </a>

                            </header>

                            <h2><a href="'.get_permalink().'">'.recortar_texto(get_the_title(),$recortartitulo).'</a></h2>

                            <footer class="ovhd">

                            	<span class="flor">'.mt_mvisitas(get_the_ID()).'<i class="icvi ico"></i></span>

                            	<i class="icda ico"></i>'.relative_date(strtotime("".get_the_date('Y')."-".get_the_date('m')."-".get_the_date('d')." ".get_the_date('H').":".get_the_date('i').":".get_the_date('s')."")).'

                            </footer>

                        </article>

                    </li>



Esta es la parte del functions.php que habría que modificar (la que he puesto en negrita). Yo lo he conseguido realizar en el index y en las categorias poniendo este codigo, pero claro en el index.php y en page.php.

Para los videos relacionados el cogido que coge es el que he puesto del fuctions, y ahí es donde no consigo poner lo mismo que en el index y en el page.

En el index y page lo he conseguido con cambiando el codigo por este:

Código:
                            <footer class="ovhd">
                            	<span class="flor"><?php echo mt_mvisitas(get_the_ID()); ?> Visitas</span>
                            	<?php echo "".get_post_meta($post->ID, "autor", $single = true); ?>
                            </footer>

y me ha funcionado


Muchas gracias y perdona tanta molestia