0
votes

I need the option to build a page showing all posts of a specific category. Showing all posts of a category can be done out-of-the-box by wordpress, I know. But I need the possibility to put some information about all those posts.

I know there's a plugin called "List category posts" (http://wordpress.org/plugins/list-category-posts/). It works but it's only showing the links to the posts. I need the full posts (like they are shown on the "blog page").

2
Create custom page and use wp_query loopTrishul

2 Answers

0
votes

If you need to "do something" to results, look at

query_posts

via http://codex.wordpress.org/Function_Reference/query_posts

Here is a sketch that I think leans towards your needs using a custom loop. This can be inserted as needed via simple logic in your template:

// this sets up the filter parameters for a category id some_cat_id sorting asc

$args = array(
    'cat'      => $some_cat_id,
    'order'    => 'ASC'
);

// The query is applied via a conditional
if($some_conditional) { // for what ever reason we use the filter+args
    query_posts( $args );
    // this is also an opportunity to "do stuff" before the loop/output
}

// The Loop (simple example)
while ( have_posts() ) : 
    the_post();
    echo '<li>';
    the_title();
    echo '</li>';
endwhile;

// Reset Query
wp_reset_query();

As a long time WP user I avoid plugins at all costs in preference of writing sustainable code. Plugins are a point of failure and some of the biggest plugin factories out there are nothing but security issues wrapped in sugar.

Custom loops via conditionals using query "filtering" is amazing and this pattern can be extended to category, search, tags, and meta key:value pairs.

Additionally, by understanding the loop the formatting and output can be controlled in a manner that is easy to sustain. Some of the plugin logic is horrid and very inefficient, so always investigate any and all plugins when performance and security are important.

0
votes

Here's what I find to be the most simple way to do this:

<?php query_posts('cat=25&showposts=3'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

//You can change up the format below any way you'd like. 
  <li class="homeblock" style="max-width:400px;">
        <div class="entry-thumbnail">
            <?php the_post_thumbnail(); ?> 
        </div>
        <div class="contentbox"><?php the_excerpt(); ?> </div>
    </li>
<?php endwhile; endif; ?>

You can add this to a theme template file and all you need to change is the category id to the category you are trying get posts from. For example if your category id is '114' and you would like to show 9 posts it would look like the following:

<?php query_posts('cat=114&showposts=9'); ?>

If you need to add more info to the posts you should consider using custom fields to do that. Check out the plugin called Advanced Custom Fields.

Here is an example of a custom field being used in a loop:

<?php query_posts('cat=25&showposts=3'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> 
  <li class="homeblock" style="max-width:400px;">
    <div class="entry-thumbnail">
        <?php the_post_thumbnail(); ?> 
    </div>
    <div class="contentbox"><?php the_excerpt(); ?> </div>              
    <?php $article_link=get_post_meta($post->ID, 'article-link', true);?>
    <?php if ( $article_link ) : ?>
    <a href="<?php  echo $article_link ?>" class="more-link"> </a>
    <?php else : ?>
    <a href="<?php the_permalink(); ?>" class="more-link"> </a> 
    <?php endif; ?> 
    </li>
<?php endwhile; endif; ?>

In the above example, if the custom field 'article-link' has a value, then that value (a URL) is used as the href in a link instead of the permalink of the article.

Hope I have helped!