Foros del Web » Creando para Internet » Sistemas de gestión de contenidos » WordPress »

Página con entradas de una categoría

Estas en el tema de Página con entradas de una categoría en el foro de WordPress en Foros del Web. Quiero hacer una página con entradas de una categoría. alguien usa esto que acabo de encontrar para hacerlo? Como lo hacéis vosotros? A Page of ...
  #1 (permalink)  
Antiguo 10/12/2013, 16:35
Avatar de Scape  
Fecha de Ingreso: octubre-2006
Mensajes: 626
Antigüedad: 17 años, 6 meses
Puntos: 7
Página con entradas de una categoría

Quiero hacer una página con entradas de una categoría. alguien usa esto que acabo de encontrar para hacerlo? Como lo hacéis vosotros?


A Page of Posts

The following custom page template file displays the content of the Page, followed by the posts from two specific categories (specified by their category slugs). It is designed to work within a child Theme of the Twenty Thirteen theme. If you are using a different theme, you need to replicate the HTML structure of your own theme within this template.

Save this to pageofposts.php and then assign the Page of Posts Template to your new Page:

<?php
/*
Template Name: Page Of Posts
*/

/* This example is for a child theme of Twenty Thirteen:
* You'll need to adapt it the HTML structure of your own theme.
*/

get_header(); ?>

<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php
/* The loop: the_post retrieves the content
* of the new Page you created to list the posts,
* e.g., an intro describing the posts shown listed on this Page..
*/
if ( have_posts() ) :
while ( have_posts() ) : the_post();

// Display content of page
get_template_part( 'content', get_post_format() );
wp_reset_postdata();

endwhile;
endif;

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

$args = array(
// Change these category SLUGS to suit your use.
'category_name' => 'music, videos',
'paged' => $paged
);

$list_of_posts = new WP_Query( $args );
?>
<?php if ( $list_of_posts->have_posts() ) : ?>
<?php /* The loop */ ?>
<?php while ( $list_of_posts->have_posts() ) : $list_of_posts->the_post(); ?>
<?php // Display content of posts ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>

<?php twentythirteen_paging_nav(); ?>

<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>

</div><!-- #content -->
</div><!-- #primary -->

<?php get_footer(); ?>
  #2 (permalink)  
Antiguo 12/12/2013, 04:48
 
Fecha de Ingreso: diciembre-2004
Ubicación: Madrid
Mensajes: 550
Antigüedad: 19 años, 3 meses
Puntos: 28
Respuesta: Página con entradas de una categoría

¿con todas las entradas de una categoría o con unas entradas determinadas?

Etiquetas: entradas, html, página, php, post, theme
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:15.