Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm not sure if I fully understand what you're trying to achieve, so my apologies if this doesn't help.</p> <p>By the looks of it you want to nest a custom loop inside a page. If you just want to customise a regular list of posts, then you should be looking at archive.php, not single.php. <a href="http://codex.wordpress.org/Template_Hierarchy" rel="nofollow">Check out this hierarchy</a> for details of the different template types. In the simplest form, archive pages are for display multiple posts (archive.php) and single pages are for displaying a single post/page (single.php).</p> <p>For a custom loop inside a page, avoid using $wp_query, as this is used for the actual page you're looking at and will drive</p> <p>For pagination, I would agree with the tutorial and use <a href="http://codex.wordpress.org/Function_Reference/paginate_links" rel="nofollow">paginate_links</a>. With a bit of CSS, this should give you the effect you want.</p> <p>So all in all, the query should look something like this in almost its simplest form.</p> <pre><code>$args=array(); // Set $args with whatever parameters for your query $args['category_name']='news_and_updates'; $args['showposts']=1; $args['paged']=(get_query_var('paged') ? get_query_var('paged') : 1); // Get the current page, or show page 1. $search=new WP_Query($args) if($search-&gt;have_posts()) : while($search-&gt;have_posts()) : $search-&gt;the_post(); the_title(); // Whatever for displaying each post. the_excerpt(); endwhile; /* Pagination - This assumes you have 'pretty permalinks'. */ $ulpn=99999999; // Should be a bigger number than the number of pages you'll ever produce. $pagination=paginate_links(array( 'base'=&gt;str_replace($ulpn,'%#%',esc_url(get_pagenum_link($ulpn))), 'format'=&gt;'/page/%#%', 'current'=&gt;max(1,get_query_var('paged')), 'total'=&gt;$search-&gt;max_num_pages, 'prev_text'=&gt;'&lt;', 'next_text'=&gt;'&gt;', 'type'=&gt;'array')); // There are other parameters you can use to customise this - check the codex using the link above. if($pagination) { ?&gt; &lt;div class="pagination"&gt;&lt;?php foreach($pagination as $page) { echo $page; } ?&gt;&lt;/div&gt; &lt;?php } else : ?&gt; &lt;h2&gt;Sorry, no results found&lt;/h2&gt; &lt;p&gt;Try searching, or using the menu to find what you're looking for.&lt;/p&gt; // Handle no results with whatever message endif; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload