Como mostrar todas as postagens da categoria no WordPress?
-
-
Porqueeunão sou um desenvolvedor,eutentei e agoraestou usando "Visualizações de conteúdo".Vocêpode usá-lo apenasparaexibirmensagens de categoria.Grandeplugin!Because I'm not a developer, I've tried and I'm now using "Content Views". You can use it to display category posts only. Great plugin!
-
4 respostas
- votos
-
- 2011-05-18
<?php $args = array( 'category' => 7, 'post_type' => 'post' ); $postslist = get_posts( $args ); foreach ($postslist as $post) : setup_postdata($post); ?> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <?php the_excerpt(); ?> <?php endforeach; ?>
Basta alterar o ID da categoria (número 7) emudar opost_type queestavanoplugin
Para sabermais sobrepost_type,consulte o link http://codex.wordpress.org/custom_post_types
<?php $args = array( 'category' => 7, 'post_type' => 'post' ); $postslist = get_posts( $args ); foreach ($postslist as $post) : setup_postdata($post); ?> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <?php the_excerpt(); ?> <?php endforeach; ?>
just change the category id (number 7) and change the post_type that was in the plugin
to learn more about post_type, see link http://codex.wordpress.org/Custom_Post_Types
-
- 2011-05-17
Émuitofácilfazê-lo com o WordPress.Vocêtem queentender que opost énormalmenteexibidoem um "loop",umpequeno código que se repete.Vocêtem que usar umparafazerisso.
<?php $catPost = get_posts(get_cat_ID("NameOfTheCategory")); //change this foreach ($catPost as $post) : setup_postdata($post); ?> <div> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <p><?php the_content(); ?></p> </div> <?php endforeach;?>
Você deve alterar a saídapara o que seencaixanas suasnecessidades
It is quite easy to do it with wordpress. You have to understand that post are normally display within a "loop", a small code that repeat itself. You have to use one to do that.
<?php $catPost = get_posts(get_cat_ID("NameOfTheCategory")); //change this foreach ($catPost as $post) : setup_postdata($post); ?> <div> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <p><?php the_content(); ?></p> </div> <?php endforeach;?>
You should change the output to what fit your needs
-
- 2018-09-21
Vocêpode usareste códigopara acessartoda apostagem de categoriaespecífica.Na sua categoria.Phppágina Use o spinet do código
$current_category = get_queried_object(); ////getting current category $args = array( 'post_type' => 'our-services',// your post type, 'orderby' => 'post_date', 'order' => 'DESC', 'cat' => $current_category->cat_ID // current category ID ); $the_query = new WP_Query($args); if($the_query->have_posts()): while($the_query->have_posts()): $the_query->the_post(); echo "<h2>".the_title()."</h2>"; echo "<p>".the_content()."</p>"; endwhile; endif;
You can use this code for accessing all post of specific category. In your category.php page use the spinet of code
$current_category = get_queried_object(); ////getting current category $args = array( 'post_type' => 'our-services',// your post type, 'orderby' => 'post_date', 'order' => 'DESC', 'cat' => $current_category->cat_ID // current category ID ); $the_query = new WP_Query($args); if($the_query->have_posts()): while($the_query->have_posts()): $the_query->the_post(); echo "<h2>".the_title()."</h2>"; echo "<p>".the_content()."</p>"; endwhile; endif;
-
- 2016-01-26
Isso é adaptado do código que alguémescreveu,e queeume beneficiei demuitotempo atráspara saber de onde veio (se apessoa que originalmenteescreveu é lerisso,obrigadonovamente).Funcionapara o seupedido:
<?php $catPost = get_posts('cat=888&posts_per_page=-1000'); foreach ($catPost as $post) : setup_postdata($post); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"> <?php the_post_thumbnail('name of your thumbnail'); ?> </a> <h4> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"> <?php the_title(); ?> </a> </h4> <hr/ style="clear:both;"> <?php endforeach;?>
This is adapted from code someone else wrote, and which I benefitted from too long ago to know where it came from (if the person who originally wrote it is reading this, thanks again). It works for your request:
<?php $catPost = get_posts('cat=888&posts_per_page=-1000'); foreach ($catPost as $post) : setup_postdata($post); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"> <?php the_post_thumbnail('name of your thumbnail'); ?> </a> <h4> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"> <?php the_title(); ?> </a> </h4> <hr/ style="clear:both;"> <?php endforeach;?>
Eu criei uma categoria usando oplugin dotipo Postpersonalizado,e agora apenas os 5postsmais recentes da categoriaestão sendoexibidos.
O queeu quero émostrartodas aspostagenspara a categoria.
Para oexame,suponha queeutenha categoria defilmes -eu querotodos osfilmesnessa categoria.
Que código devo usare onde?
Eunão seimuito sobre o WordPress,entãoeu apreciaria umprocessopasso apasso.