• Resolved christyroo

    (@christyroo)


    https://www.mtassisi.org

    On my site, the top drop-down menu ought to contain each post in the specified category. I used get_posts to do this; however, both the ABOUT and ACADEMICS are listing posts that aren’t in their categories. I’ve double-checked to make sure each post is in the right category and each category doesn’t have a parent or anything. Is there something that I’m missing? Here’s my get_posts:

    <?php
     global $post;
     $myposts = get_posts('numberposts=-1&category=5&orderby=post_title&order=ASC');
     foreach($myposts as $post) :
     setup_postdata($post);
     ?>
     <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
     <?php endforeach; ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • Just to understand.

    I click on About in the header menu and see a pull down starting with Board of Directors, Contact & Location Information, Entrance Exam, etc. Each of those is really just a post in a specific Category?

    Thread Starter christyroo

    (@christyroo)

    Yes, that’s the way it’s supposed to work.

    However, posts such as “Uniforms & Spirit Items” belong only in ADMISSIONS and not in ABOUT. I don’t understand why it would show up in both categories! Thanks for your help!

    Thread Starter christyroo

    (@christyroo)

    For anyone else with this problem:

    I had the “&” symbol in the title of some of posts, and as a result, it added those posts to get_posts even if the category didn’t match. Strange!

    Was unable to duplicate your problem, but in researching this, found that get_posts could return invalid data. I reported on Trac Ticket 5317.

    Would be interested to hear your thoughts, christyroo.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘get_posts is retrieving too much’ is closed to new replies.