Como mostrar numero limitado de post en mi tamplate

Foro de habla español

Como mostrar numero limitado de post en mi tamplate

Postby Burlon23 » 1:52pm, Tue 17 Mar, 2015

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:

Code: Select all
<?php
$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:



Code: Select all
 <?php

// get only first 3 results
$ids = get_field('selector_de_noticias', false, false);

$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.
Burlon23
phpList newbie
 
Posts: 2
Joined: 1:47pm, Tue 17 Mar, 2015

Re: Como mostrar numero limitado de post en mi tamplate

Postby Dragonrider » 2:59pm, Tue 17 Mar, 2015

To help people to help you, can you please mention the version of phpList that this refers to?
My sites:- http://wharfedalefestival.co.uk, http://ilkleygardeners.org.uk, http://emergencyaid.net, http://dragonrider.co.uk
Latest phpList version is now 3.0.12 (3 February 2015) and requires a minimum of MySQL 5.0 and PHP 5.3.x
Dragonrider
Moderator
 
Posts: 3460
Joined: 6:58am, Sun 02 Jul, 2006
Location: Ilkley, West Yorkshire, United Kingdom

Re: Como mostrar numero limitado de post en mi tamplate

Postby Burlon23 » 3:07pm, Tue 17 Mar, 2015

Dragonrider wrote:To help people to help you, can you please mention the version of phpList that this refers to?


Hello Dragonrider, I am newbie in php, not what you mean with the version of phplist, could you explain ?, Greetings
Burlon23
phpList newbie
 
Posts: 2
Joined: 1:47pm, Tue 17 Mar, 2015

Re: Como mostrar numero limitado de post en mi tamplate

Postby Dragonrider » 4:01pm, Tue 17 Mar, 2015

This is a forum for phpList, not PHP.

Currently there are two versions, version 2 and version 3.
Version 2 ran to 2.11.x whilst Version 3 is currently at 3.0.12

So, which version does your post refer to please? If you can supply this info, perhaps someone will know what you are asking and how to help.
My sites:- http://wharfedalefestival.co.uk, http://ilkleygardeners.org.uk, http://emergencyaid.net, http://dragonrider.co.uk
Latest phpList version is now 3.0.12 (3 February 2015) and requires a minimum of MySQL 5.0 and PHP 5.3.x
Dragonrider
Moderator
 
Posts: 3460
Joined: 6:58am, Sun 02 Jul, 2006
Location: Ilkley, West Yorkshire, United Kingdom


Return to Spanish forum

Who is online

Users browsing this forum: No registered users and 2 guests