• Hi,

    I am trying to put all of my posts from the “tutorial” category on a page. I have used this, but it does not work :

    <?php
    $catPost = get_posts(get_cat_ID("3")); //change this
       foreach ($catPost as $post) : setup_postdata($post); ?>
    
    <h1><a>"><?php the_title(); ?></a></h1>
        <?php the_excerpt(); ?> 
    
    <p class="postinfo">Written by: <?php the_author_posts_link(); ?>
    Posted on: <?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?>
    Categories: <?php the_category(', '); ?></p>
    <hr />
    <?php  endforeach;?>

    It also shows posts from other categories: https://mybluebox.dearestdesigns.com/?cat=3

    I previously tried this one, but it says error on line 17.

    <?php
    // The Query
    query_posts( array ( 'category_name' => 'tutorials', 'posts_per_page' => -1 ) );
    ?>
    
        <?php
    // The Loop
    while ( have_posts() ) : the_post();
    	echo '<h1>';
    	the_title();
    	echo '</h1>';
    	the_excerpt();
    	echo ' <p class="postinfo">Written by: ';
    	the_author_posts_link();
    	echo 'Posted on '
    	the_date();
    	echo 'Categories: '
    	the_category(', ');
    	echo '</p>'
    	endwhile; ?>
    
    	  <?php
    
    	  // Reset Query
    	  wp_reset_query();
    
    	  ?>

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display all posts from one category’ is closed to new replies.