Member Avatar for T4gal

Hello,

I posted this in the Wordpress discussion forum but have not got a response, so I thought I might try here. Hopefully I have posted this in the right category, if not please let me know.

I have two categories for posts and two pages to display these posts. One category works just fine, everything displays correctly (this is the first category I created), but the other category that I added after, doesn't display posts in single view when you click their title. It shows all of the posts in that category. Nothing changes except the URL. The URL displays correctly, but the single post view just doesn't work.

I've checked google and can't find anything like this problem. I have no idea how one category works and the other does not. As far as I can tell everything is done exactly the same between the two. I have the permalinks set to /%category%/%postname%/ if that matters. If I change it to /%postname%/ then the posts in the category that isn't working just won't come up at all.

I am using a child theme based off twentyeleven.
I am using a pageofposts template for the pages that display the post categories, a separate one for each but they are exactly the same, just different category names in the code.

I appreciate any help, and please let me know if you need more information.

Here is the page of the category that doesn't work, the one that does work is "Setup Sheets"

http://www.jjwangracing.com/racing-history/

Recommended Answers

All 5 Replies

Would it be possible for you to post the code for one of the pageofposts files (since you said they're both pretty much the same anyway)?

Also, could you just confirm that there are two categories created and all posts are the same (were created using Posts > Add New) and the only difference between them all is whether they have a category of racing-history or setup-sheets.

Member Avatar for T4gal

Hello,

Thank you for the reply.

Yes, two categories and I have tried creating multiple test posts, doing the exact same steps, Posts > Add New, fill in a simple title and a few words in the content, select the category and post it. I've also tried creating a new post under the "Racing History" category and when it doesn't work, I go in and edit the post, changing it from "Racing History" to "Setup Sheets" and that post still will not work. It seems as though if a post has ever been associated with the "Racing History" category, it will never work, even if it has been switched to another category. You can see that example by looking at the "2012" post that is now under "Setup Sheets".

Here is the code I am using for the page of posts.The only bit that is different between the two is the category name.

<?php
/*
Template Name: Page Of Posts History
*/

// if you are not using this in a child of Twenty Eleven, you need to replicate the html structure of your own theme.

get_header(); ?>
<div id="primary">
<div id="content" role="main">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args= array(
    'category_name' => 'racing-history', // Change these category SLUGS to suit your use.
    'paged' => $paged
);
query_posts($args);
if( have_posts() ) :?>

<?php twentyeleven_content_nav( 'nav-above' );?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php twentyeleven_content_nav( 'nav-below' ); ?>

<?php else : ?>
<article id="post-0" class="post no-results not-found">
<header class="entry-header">
<h1 class="entry-title"><?php _e( 'Nothing Found', 'twentyeleven' ); ?></h1>
</header><!-- .entry-header -->

<div class="entry-content">
<p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyeleven' ); ?></p>
<?php get_search_form(); ?>
</div>
<?php endif; ?>
</div>
</div>
<?php get_footer();
Member Avatar for T4gal

Does anyone have any idea what I did wrong or how I can fix it?

Sorry, I've been away from DaniWeb for a few days. It seems like your setup-sheets single posts are calling the correct template file, probably post.php. However, your racing-history single posts seem to be calling the pageofposts template.

It's very hard to pinpoint what's gone wrong in these WordPress child themes and, while I wouldn't advise using them, it seems like your solution should be working just fine. The individual posts should be calling the post.php file when you click the permalink, so you could always check that and make sure it's not doing anything strange in there.

Member Avatar for T4gal

Hello,

Thank you for the help, I did manage to figure it out. It was simply my slugs that were messing it up. Apparently using 2005, 2006, etc. as the slug causes problems. As soon as I changed them it worked just fine.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.