title: How do I get pagination to work for get_posts() in WordPress?
body: <p>I'm working on a WordPress site and I've created a page template that displays posts by a category slug. To do this, I create a field for the page, WP_Catid, and set it equal to the category slug I want to display posts from. However, I only want five posts to show up per page with pagination links at the bottom of those posts. How do I get the pagination links to display properly?</p>
  
  <p>My code is as follows:</p>
  
  <pre><code>&lt;div id="container"&gt;
    &lt;div id="content" role="main"&gt;
      &lt;?php
        $btpgid=get_queried_object_id();
        $btmetanm=get_post_meta( $btpgid, 'WP_Catid','true' );
        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  
        $args = array( 'posts_per_page' =&gt; 5,
                       'category_name' =&gt; $btmetanm,
                       'paged' =&gt; $paged,
                       'post_type' =&gt; 'post' );
  
        $myposts = get_posts( $args );
        foreach ( $myposts as $post ) : setup_postdata( $post ); 
          echo "&lt;div style='border:2px groove black; margin-bottom:5px;'&gt;&lt;h3 class='btposth'&gt;";
          the_title(); 
          echo "&lt;/h3&gt;&lt;div class='btpostdiv'&gt;";
          the_content();
          echo "&lt;/div&gt;&lt;/div&gt;";
        endforeach; 
        next_posts_link( 'Older Entries'); //not displaying
        previous_posts_link('Newer Entries &amp;raquo;'); //not displaying
        wp_reset_postdata();
      ?&gt;
    &lt;/div&gt;&lt;!-- #content --&gt;
  &lt;/div&gt;&lt;!-- #container --&gt;
  </code></pre>