Note that there are some explanatory texts on larger screens.

plurals
  1. POWordpress custom taxonomy paged getting 404 not found
    text
    copied!<p>I have a custom taxonomy called "dcategory" so I have created a template file called "taxonomy-dcategory.php" to determine how its shown. Here is the code for this template:</p> <pre><code>&lt;?php global $paged, $wp_query; get_header(); ?&gt; &lt;div id="leftcontent"&gt; &lt;?php if(is_user_logged_in()) : ?&gt; &lt;?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); if($term-&gt;parent == 0) : ?&gt; &lt;h1&gt;Specialist Directory&lt;/h1&gt; &lt;h2&gt;&lt;?php echo $term-&gt;name; ?&gt;&lt;/h2&gt; &lt;ul&gt; &lt;?php $subtermcats = get_terms('dcategory', 'hide_empty=0&amp;parent='.$term-&gt;term_id.'&amp;orderby=name'); foreach($subtermcats as $key =&gt; $data) { $termlink = get_term_link($data, 'dcategory'); echo "&lt;li&gt;&lt;a href=\"".$termlink."\"&gt;".$data-&gt;name."&lt;/a&gt;&lt;/li&gt;"; } ?&gt; &lt;/ul&gt; &lt;?php else: ?&gt; &lt;h1&gt;Specialist Directory&lt;/h1&gt; &lt;?php $topterm = get_term_by( 'id', $term-&gt;parent, get_query_var( 'taxonomy' ) ); ?&gt; &lt;h2&gt;&lt;?php echo $topterm-&gt;name; ?&gt; &amp;gt; &lt;?php echo $term-&gt;name; ?&gt;&lt;/h2&gt; &lt;?php // Include Search - Search results returned in $_SESSION['lpoc_search_data']; include("functions/directorysearch.php"); if(count($_SESSION['lpoc_search_data']) &gt; 0) { $temp = $wp_query; $wp_query = null; $args = array( 'post_type' =&gt; 'listings', 'post__in' =&gt; $_SESSION['lpoc_search_data'], 'showposts' =&gt; 10, 'paged' =&gt; $paged, 'orderby' =&gt; 'post__in' ); $wp_query = new WP_Query($args); } else { query_posts("cat=9999999"); // Make a fake query that will be empty to flush out the content from the page we are on } ?&gt; &lt;?php if (have_posts()) : ?&gt; &lt;div class="pageination clearfix"&gt; &lt;div class="smallleftcontent"&gt; &lt;select name="sortby" class="dropdownreplace"&gt; &lt;option value="date-desc"&gt;Order by latest added&lt;/option&gt; &lt;option value="date-asc"&gt;Order by oldest added&lt;/option&gt; &lt;option value="price-asc"&gt;Order by price ascending&lt;/option&gt; &lt;option value="price-desc"&gt;Order by price descending&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;div class="smallrightcontent"&gt; &lt;?php wp_pagenavi(); ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php while (have_posts()) : the_post(); ?&gt; &lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;/h2&gt; &lt;?php endwhile; ?&gt; &lt;div class="pageination clearfix"&gt; &lt;div class="smallleftcontent"&gt; &lt;select name="sortby" class="dropdownreplace"&gt; &lt;option value="date-desc"&gt;Order by latest added&lt;/option&gt; &lt;option value="date-asc"&gt;Order by oldest added&lt;/option&gt; &lt;option value="price-asc"&gt;Order by price ascending&lt;/option&gt; &lt;option value="price-desc"&gt;Order by price descending&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;div class="smallrightcontent"&gt; &lt;?php wp_pagenavi(); ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php else: ?&gt; &lt;?php endif; ?&gt; &lt;?php endif; ?&gt; &lt;?php else: // USER NOT LOGGED IN ?&gt; &lt;?php include("functions/pleaseregister.php"); ?&gt; &lt;?php endif; ?&gt; &lt;/div&gt; &lt;?php get_sidebar(); ?&gt; &lt;?php get_footer(); ?&gt; </code></pre> <p>Here is what is happening:</p> <p>Check if user is logged in. If not show register info. If user is on a parent dcategory then the chosen dcategory children is shown. If user is on child dcategory then run my own custom brewed database query that gets IDs of posts in an order based on distance from user to post. Results are returned in a session array and passed as a custom query to $wp_query. The query works and the page shows the first ten posts along with the pagination generated by wp_pagenavi (all correct).</p> <p>But when navigating to page 2 I am returned a page not found:</p> <p><a href="http://www.example.com/dcategory/antiques/" rel="nofollow">http://www.example.com/dcategory/antiques/</a> to <a href="http://www.example.com/dcategory/antiques/page/2/" rel="nofollow">http://www.example.com/dcategory/antiques/page/2/</a></p> <p>Any ideas why this is happening?</p> <p>Thanks</p> <p>Scott</p>
 

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