Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am working on a site and am having an issue with one of the categories. There is plenty of content on the site and there are seven different categories. All of the categories display the correct posts except for the very last one. I've searched all around and have not seen this exact issue come up (oftentimes, people just have the wrong posts in all their categories).

Please see the URL I'm working with. It is http://www.glossandglam.com/blog/ and the category that is not working is "Tutorials." Thanks for any help you can provide.

EDIT

Here is code for more detail:

<?php if (have_posts()) : ?>

<ul style="list-style-type:none;">

<?php

if ($paged == 0)
  $offset = 0;
else
  $offset = ($paged - 1) * 11;
global $post;
$category = get_the_category($post->ID);
$category = $category[0]->cat_ID;
$myposts = get_posts(array('numberposts' => 11, 'offset' => $offset, 'category__in' => array($category), 'post__not_in' => array($post->ID),'post_status'=>'publish'));
foreach($myposts as $post) :
setup_postdata($post);

?>


<li id="category_li">
    <div id="image_con">
        <div id="image_recent">
        <a href="<?php the_permalink(); ?>"><?php set_post_thumbnail_size( 200, 200 );
the_post_thumbnail(); ?></a>
        </div>
    </div>

    <div id="cr_content">
    <a href="<?php the_permalink(); ?>">
    <div class="gloss_glam_font"> <?php the_title(); ?></div>
    <hr>
    <div class="excerpt_cat"><?php the_excerpt(); ?></div>
    </a>
    </div>

    <div id="clearfix">
    </div>
</li>

<?php endforeach; ?>
<?php wp_reset_query(); ?>
</ul>

A quick explanation is that we are displaying 11 posts per page with a custom pagination at the bottom. I am using the "Category Post List Widget" plugin to style the list items that are being generated.

share|improve this question
1  
This question is impossible to answer without seeing any code. The "tutorials" archive index appears to be displaying posts from other categories. Are you modifying the query directly (e.g. via query_posts()) anywhere? Do you have a customized loop in one of your template files? –  Chip Bennett Aug 28 '12 at 16:54
    
I will add my customized loop. One sec. Thanks for getting this started. –  MxmastaMills Aug 28 '12 at 17:22
    
Alright, I've added more code above. –  MxmastaMills Aug 28 '12 at 17:28
    
What template file is this? Or, in what template file is this loop code called? Also: why are you hacking up the loop query this much, just to get 11 posts per page? –  Chip Bennett Aug 28 '12 at 18:54

1 Answer 1

up vote 1 down vote accepted

The problem is almost assuredly your custom loop.

I am guessing that this is your problem:

$category = get_the_category($post->ID);
$category = $category[0]->cat_ID;

Further, I'm guessing that the $post object being queried here has more than one category term defined. Thus, $category[0] is returning something other than "tutorials".

Easiest solution: ensure all posts only have one category term defined.

More complex, but more future-proof and stable, solution: eliminate the use of the Category Post List Widget Plugin, go back to using the default query loop, and define your markup/style as necessary for your archive index pages.

share|improve this answer
    
Ok great, thank you. You've nailed it without me even telling you all the details. I'm still learning all of this and I appreciate your help! –  MxmastaMills Aug 28 '12 at 20:41
    
One more question Chip. Is there any way you could point me in the right direction to get back to the default query loop for an archive page? I've gotten myself so far from the default that I'm having a hard time getting back to the start. Thanks again. –  MxmastaMills Aug 28 '12 at 20:56
    
And the reason I was using the long code was that I was having trouble doing pagination with the post query. I figured I'd just have the page pull the posts according to the page number of the archive it was on. I suppose there is a simpler way to do it? –  MxmastaMills Aug 28 '12 at 21:07
    
I'd be happy to! You might want to open a new question, asking specifically what you need. Perhaps something like, "How to modify the loop to have 11 posts per page", and then provide details in the question (such as: only for category archive index pages, etc.). I would normally suggest editing this question, but really, they're two completely different types of questions. –  Chip Bennett Aug 28 '12 at 21:26
    
Great, thanks! I was considering that because I didn't want you or someone else to help me without getting credit. I'll post the link when I have it up. Thanks! –  MxmastaMills Aug 28 '12 at 21:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.