Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/03/2015, 00:10
Burlon23
 
Fecha de Ingreso: marzo-2015
Ubicación: Buenos Aires
Mensajes: 32
Antigüedad: 9 años, 1 mes
Puntos: 0
Pregunta Como mostrar numero limitado de post en mi tamplate

Hola, tengo un problema en utilizar (posts_per_page) hacia un (custom fields).

Tengo un custom fields llamado (selector_de_noticias), este fields es un relationship, que se encarga de relacionarme dos Custom Post Types entre si, mis Custom Post Types son Eventos (eventosae) y Noticias (noticiasparaeventos).

Bueno mi problema es que logro mostrar el (custom fields) [mostrandome las Noticias relacionadas al Evento], pero no quiero que me aparezcan todas las noticias, sino solo 3 noticias, que luego yo le agregaria (no se como) un "Ver mas Noticias", sin mas, aca les dejo el codigo que estoy utilizando para mostrar las Noticias Relacionadas a uno de mis Eventos:

Código PHP:
<?php 

/************* FUNCION DE EXTRACTO (by Braulio)******************/
function extracto_noticia($post$length 10$tags '<a><em><strong>'$extra ' . . .') {
 
    if(
is_int($post)) {
        
// get the post object of the passed ID
        
$post get_post($post);
    } elseif(!
is_object($post)) {
        return 
false;
    }
 
    if(
has_excerpt($post->ID)) {
        
$the_excerpt $post->post_excerpt;
        return 
apply_filters('the_content'$the_excerpt);
    } else {
        
$the_excerpt $post->post_content;
    }
 
    
$the_excerpt strip_shortcodes(strip_tags($the_excerpt), $tags);
    
$the_excerpt preg_split('/\b/'$the_excerpt$length 2+1);
    
$excerpt_waste array_pop($the_excerpt);
    
$the_excerpt implode($the_excerpt);
    
$the_excerpt .= $extra;
 
    return 
apply_filters('the_content'$the_excerpt);
}
/************* FUNCION DE EXTRACTO FIN (by Braulio)******************/





/************* OBTENER EL FIELD DE ACF (by Braulio)******************/
$posts get_field('selector_de_noticias');

if( 
$posts ): ?>

    <div id="columna_evento_1">

    <div id="div_titulo_noticias_evento">
    <a class="titulo_noticias_evento">Noticias del Evento</a>
    </div>
    
    <div id="div_noticias_evento">
    
    <?php foreach( $posts as $p ): // variable must NOT be called $post (IMPORTANT) ?>
    
        <li>
        
           <a class="titulo_noticia_evento_link" href="<?php echo get_permalink$p->ID ); ?>"><?php echo get_the_title$p->ID ); ?></a>
        <div class="imagen_noticia_evento"> <?php echo get_the_post_thumbnail$p->ID ); ?> </div>
        <p><?php echo extracto_noticia($p); ?></p>
        
        </li>
        
    <?php endforeach; ?>
    
    </div>
    </div>
    
<?php endif;?>


Y aca les dejo lo que deberia introducir, es solo que no se como adaptarlo a mi código:


Código PHP:
<?php 

// get only first 3 results
$ids get_field('selector_de_noticias'falsefalse);

$query = new WP_Query(array(
    
'post_type'          => 'ACA NO SE SI VA   noticiasparaeventos   Ó   eventosae   IGUAL CON NINGUNO DE LOS DOS ME FUNCIONA',// Ó no se como adaptarlo a mi código
    
'posts_per_page'    => 3,
    
'post__in'        => $ids,
    
'post_status'        => 'any',
    
'orderby'            => 'rand',
));

?>

Espero me puedan ayudar, muchisimas gracias de ante mano.