Reputation: 415
I am working with wordpress and think I may have made a big mistake along the line somewhere. Initially I noticed that when browsing to my archive.php page I was getting a set of post but the pagination wasn't working. So for example I browsed to an athour archive, the author has 10 posts but my site limit is set to display 5 posts on a page. I see the 5 posts and a link to the next page, but clicking on the link takes me to a 404.
I have altered the WP Query at the top of the archive page, so I figured it was a problem with that...
Anyway, to cut a long story short I stripped back the entire archive page to the very bare example below. Using this as the code for the archive.php page always returns the 'there is no post' text, even though I am viewing the same author's archive page.
Help!
<?php get_header(); ?>
<?php if ( have_posts() ) : ?>
<h1>We have posts!</h1>
<?php while ( have_posts() ) : the_post(); ?>
<p>There is a post here</p>
<?php endwhile; ?>
<?php else : ?>
<p>there is no post here</p>
<?php endif; ?>
<div><?php posts_nav_link(' ','Previous Page','Next Page'); ?></div>
<div><?php posts_nav_link(' ','Go Back','Go Back'); ?></div>
My header.php looks like:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/reset.css" />
<link rel="stylesheet" href="<?php echo get_stylesheet_uri(); ?>" />
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<section id="content" role="main">
Upvotes: 1
Views: 376
Reputation: 5825
You may have altered the posts query in a sidebar or in your functions.php file. Try using wp_reset_query()
to check.
(Codex: wp_reset_query)
<?php
get_header();
wp_reset_query();
if ( have_posts() ) : ?> ...
Upvotes: 1
Reputation: 413
There are no errors in your code according to wordpress. These must be an error in your header file or somewhere else.
Upvotes: 0