Support » Themes and Templates » Loading a Category within a Page: Page became a duplicate Post

  • I set this page to load a category of posts, “music”. This category only has one actual post at the moment, yet two posts are showing on the page. Both the normal header for the page and the mystery second post are id=”post-84″. This page’s template is pretty much the same as most of the others, like this one, which doesn’t have the same problem.

    It may have something to do with the fact that both the “music” page and category URLs were the same at one point… but I changed the URLs, I deleted both the category and the page and made new replacements, and neither worked.

    This is the template of the problem page:

    <? /* Template Name: Music */ ?>
    
    <?php get_header(); ?>
    
    <?php get_sidebar(); ?>
    
    <!-- page-music.php -->
    
    <div id="content" class="page">
    	<?php if (have_posts()) : ?>
    	<?php while (have_posts()) : the_post(); ?>
    
    		<div class="post" id="post-<?php the_ID(); ?>">
    			<h2><?php the_title(); ?></h2><br />
    
    			<?php the_content(); ?>
    
    		</div>
    	<?php endwhile; ?>
    
    	<?php endif; ?>  
    
    <?php
    query_posts('cat=7');
    if(have_posts()) :
    while(have_posts()) :the_post();
    ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    			<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    
    			<p><?php the_content('Yes, please continue...'); ?></p><br />
    		</div>
    <?php
    endwhile;
    endif;
    wp_reset_query();?>
    
    			<?php edit_post_link('Edit this page', '<p>', '</p>'); ?>
    </div>
    
    <!-- end page-music.php -->
    
    <?php get_footer(); ?>
Viewing 1 replies (of 1 total)
  • Update: The problem is still not fixed, but I have worked around it for the time being (and now the URLs above lead directly to the categories instead of pages). If anyone knows what happened I’d still like to know so I can switch it back to pages.

Viewing 1 replies (of 1 total)
  • The topic ‘Loading a Category within a Page: Page became a duplicate Post’ is closed to new replies.