Mostrar solo post de una categoría en plantilla Adapt

  • Autor Autor Dhampire
  • Fecha de inicio Fecha de inicio
Dhampire

Dhampire

Épsilon
Verificación en dos pasos activada
Buenas tardes / noches / días gente de foro beta, estoy peleando con un código que no quiere quedar tal como quiero que quede.

He bajado la plantilla "Adapt " de Enlace eliminado y lo he modificado tanto que ya no vale la pena cambiar a estas alturas.

En la sección de "Recent News" esta el código siguiente, pero quisiera que solo se muestre una categoría determinada.

http://forobeta.com/wordpress/17506-ultimos-post-de-2-categorias-index.html
he buscado por el foro y esto me ha funcionado en partes.

Saludos
Insertar CODE, HTML o PHP:
   <?php
    //get post type ==> regular posts
        global $post;
        $args = array(
            'post_type' =>'post',
            'numberposts' => '4'
        );
        $blog_posts = get_posts($args);
    ?>
    <?php if($blog_posts) { ?>        
        <section id="home-posts" class="clearfix">
            <h2 class="heading"><span><?php if(!empty($options['recent_work_text'])) { echo $options['recent_news_text']; } else { _e('Recent News','adapt'); }?></span></h2>
            <?php
            $count=0;
            foreach($blog_posts as $post) : setup_postdata($post);
            $count++;
            //get portfolio thumbnail
            $feat_img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'grid-thumb');
            ?>
            
            
            <article class="home-entry <?php if($count == '4') { echo 'remove-margin'; } if($count == '3') { echo ' responsive-clear'; } ?>">
            	<?php if ($feat_img) {  ?>
                <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php echo $feat_img[0]; ?>" height="<?php echo $feat_img[2]; ?>" width="<?php echo $feat_img[1]; ?>" alt="<?php echo the_title(); ?>" /></a>
                <?php } ?>
                <div class="home-entry-description">
                    <h3><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php echo the_title(); ?></a></h3>
                    <?php echo excerpt('15'); ?>
                </div> 
                <!-- /home-entry-description -->
            </article>
            <!-- /home-entry-->
            <?php
            if($count == '4') { echo '<div class="clear"></div>'; $count=0; }
            endforeach; ?>
        </section>
        <!-- /home-posts -->      	
    <?php } ?>
 
quizas esto te pueda servir
PHP:
<?php $recent = new WP_Query("cat=00000&showposts=3"); while($recent->have_posts()) : $recent->the_post();?>
cat=00000
cambia ese numero por el ID de la categoria
Suerte

- - - Actualizado - - -

Buenas tardes / noches / días gente de foro beta, estoy peleando con un código que no quiere quedar tal como quiero que quede.

He bajado la plantilla "Adapt " de Enlace eliminado y lo he modificado tanto que ya no vale la pena cambiar a estas alturas.

En la sección de "Recent News" esta el código siguiente, pero quisiera que solo se muestre una categoría determinada.

http://forobeta.com/wordpress/17506-ultimos-post-de-2-categorias-index.html
he buscado por el foro y esto me ha funcionado en partes.

Saludos
Insertar CODE, HTML o PHP:
   <?php
    //get post type ==> regular posts
        global $post;
        $args = array(
            'post_type' =>'post',
            'numberposts' => '4'
        );
        $blog_posts = get_posts($args);
    ?>
    <?php if($blog_posts) { ?>        
        <section id="home-posts" class="clearfix">
            <h2 class="heading"><span><?php if(!empty($options['recent_work_text'])) { echo $options['recent_news_text']; } else { _e('Recent News','adapt'); }?></span></h2>
            <?php
            $count=0;
            foreach($blog_posts as $post) : setup_postdata($post);
            $count++;
            //get portfolio thumbnail
            $feat_img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'grid-thumb');
            ?>
            
            
            <article class="home-entry <?php if($count == '4') { echo 'remove-margin'; } if($count == '3') { echo ' responsive-clear'; } ?>">
            	<?php if ($feat_img) {  ?>
                <a rel="nofollow" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php echo $feat_img[0]; ?>" height="<?php echo $feat_img[2]; ?>" width="<?php echo $feat_img[1]; ?>" alt="<?php echo the_title(); ?>" /></a>
                <?php } ?>
                <div class="home-entry-description">
                    <h3><a rel="nofollow" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php echo the_title(); ?></a></h3>
                    <?php echo excerpt('15'); ?>
                </div> 
                <!-- /home-entry-description -->
            </article>
            <!-- /home-entry-->
            <?php
            if($count == '4') { echo '<div class="clear"></div>'; $count=0; }
            endforeach; ?>
        </section>
        <!-- /home-posts -->      	
    <?php } ?>


te funciono?
 
La verdad que no me funcionó!


quizas esto te pueda servir
PHP:
<?php $recent = new WP_Query("cat=00000&showposts=3"); while($recent->have_posts()) : $recent->the_post();?>
cat=00000
cambia ese numero por el ID de la categoria
Suerte

- - - Actualizado - - -




te funciono?

- - - Actualizado - - -

O que al menos en ese código que he compartido no aparezcan determinadas categorías 😉
 
Que raro que no te funcione, generalmente no falla :ambivalence:
 
Si, si me funcionó.
Era cuestión de ponerle un poco de atención a código.

Gracias
 
Atrás
Arriba