• I’m at a loss with this one. I’ve got permalinks activated for a WordPress blog I’m working on for a client, but I unfortunately can’t link to the page since it’s an internal/private blog.

    What’s going on is that I have my .htaccess file setup perfectly, I have the Apache server reading mod_rewrite, and I have the permalinks set to this structure: /%category%/%postname%/ — but the problem is that whenever I try to move to the next page (ie. https://blog.com/page/2/) I get a 404 error. My sidebar however is linking properly to the blog posts (ie. https://blog.com/category-name/post-name/).

    I’m going nuts trying to figure out what the problem is here. I even switched servers.

    Anyone have any idea what the problem may be???

Viewing 5 replies - 1 through 5 (of 5 total)
  • Are you using query_posts?

    Thread Starter outbreak

    (@outbreak)

    Yes. I’ve used this code to show one category on the home page:

    <?php query_posts ($query_string . '&cat=1'); ?>
    
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    			<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    				<div class="avatar"><?php echo get_avatar( get_the_author_email(), '50' ); ?></div>
    				<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
    				<div class="meta">Posted on <?php the_time('F jS, Y') ?> by <?php the_author() ?> with <?php comments_number('No Comments', '1 Comment', '% Comments'); ?> <?php edit_post_link('Edit this Post', '[', ']'); ?></div>
    				<p><?php the_content('Read the rest of this entry &raquo;'); ?></p>
    			</div>
    
    			<div class="comments"><?php comments_template(); ?></div>
    
    		<?php endwhile; ?>
    
    		<div id="pageno"><?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?></div>
    	<div class="clear"></div>
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.</p>
    		<?php get_search_form(); ?>
    
    	<?php endif; ?>

    Try changing:

    <?php query_posts ($query_string . '&cat=1'); ?>
    to:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args= array(
    	'cat' => 1,
    	'paged' => $paged
    );
    query_posts($args);
    ?>

    If that doesn’t help, try replacing <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?> with either posts_nav_link or next_posts_link / previous_posts_link.

    Thread Starter outbreak

    (@outbreak)

    Hmm, neither seem to work. I’ve been toying with the both of them trying multiple instances for the past 2 weeks and I can’t get either to work.

    Now the monthly archives aren’t working anymore either. Site went live by the way, any idea?

    https://blog.spectrum1-ent.net/

    Thread Starter outbreak

    (@outbreak)

    This is my entire code structure for the home page:

    <?php
    /**
     * @package WordPress
     * @subpackage Default_Theme
     */
    
    get_header(); ?>
    
    	<?php query_posts ($query_string . '&cat=1'); ?>
    
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    			<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    				<div class="avatar"><?php echo get_avatar( get_the_author_email(), '50' ); ?></div>
    				<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
    				<div class="meta">Posted on <?php the_time('F jS, Y') ?> by <?php the_author() ?> with <?php comments_number('No Comments', '1 Comment', '% Comments'); ?> <?php edit_post_link('Edit this Post', '[', ']'); ?></div>
    				<p><?php the_content('Read the rest of this entry &raquo;'); ?></p>
    			</div>
    
    			<div class="comments"><?php comments_template(); ?></div>
    
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    		</div>
    
    	<div class="clear"></div>
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.</p>
    		<?php get_search_form(); ?>
    
    	<?php endif; ?>
    
    	</div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Permalinks and 404 Errors at random times’ is closed to new replies.