title: List all pages from a category in Wordpress
body: <p>I'm in the middle of a small crisis here. I need your help! I've done my research for hours but this is my last resort. Cutting to the story, I'm trying to list all the 'pages' from an active category in Wordpress. </p>
  
  <p>Here are the steps I've done so far. I was able to enable categories for my pages by adding the following code to my <strong>functions.php</strong> file:</p>
  
  <pre><code>function jh_cats() {  
      register_taxonomy_for_object_type('post_tag', 'page'); 
      register_taxonomy_for_object_type('category', 'page');
  }
  add_action( 'init', 'jh_cats' );
  </code></pre>
  
  <p>Next, I needed to make it so that the website has categories &amp; sub-categories. The sub-categories will only show on the category page of the parent. I've added the following to my <strong>category.php</strong> file to get the list of all my sub-categories.</p>
  
  <pre><code>&lt;?php
  
  $categories = get_categories( array(
      'orderby' =&gt; 'name',
      'parent'  =&gt; $cat,
      'hide_empty' =&gt; FALSE
  ) );
  if ($categories)
  {
      foreach ( $categories as $category ) 
      {?&gt;         
          &lt;li&gt;&lt;a href="&lt;?php echo $category-&gt;slug ?&gt;"&gt;&lt;?php echo $category-&gt;name ?&gt;&lt;/a&gt;&lt;/li&gt;                         
  &lt;?php 
      }
  } ?&gt;
  </code></pre>
  
  <p>Now, when you visit a specific sub-category (considering nothing will be assigned to the main one), I need to be able to list all the pages that is assigned that sub-category. </p>
  
  <p><strong>What can I do next?</strong> I have this in my <strong>index.php</strong> but this just lists all the <strong>pages</strong>. Regardless if you're in a specific category or not.</p>
  
  <pre><code>&lt;ul&gt;
      &lt;?php
      global $post;
  
      $myposts = get_posts( array(
          'post_type' =&gt; 'page',
          'posts_per_page' =&gt; 5
      ) );
  
      if ( $myposts ) {
          foreach ( $myposts as $post ) : 
              setup_postdata( $post ); ?&gt;
              &lt;li&gt;
                  &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;
                  &lt;?php the_content(); ?&gt;
              &lt;/li&gt;
          &lt;?php
          endforeach;
          wp_reset_postdata();
      }
      ?&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Hope you can help! Thanks. :)
  Credits to replies/code from others over here to help me solve some of the earlier issues.</p>