Forum Replies Created

Viewing 6 replies - 16 through 21 (of 21 total)
  • Forum: Hacks
    In reply to: $recent->query of cat problem
    Thread Starter rt49andellis

    (@rt49andellis)

    The answer is
    $recent = new WP_Query( array( 'category__in' => $catID ) );

    Thank you EVERYONE for helping me out!!!

    Forum: Hacks
    In reply to: $recent->query of cat problem
    Thread Starter rt49andellis

    (@rt49andellis)

    I think that might actually be working correctly and it’s picking up parent/child stuff.

    categories 3&4 are children of 23
    category 3 is a child of 4

    How do I tell it to ignore parents & children?

    Forum: Hacks
    In reply to: $recent->query of cat problem
    Thread Starter rt49andellis

    (@rt49andellis)

    I’m not getting that one to work either. I know I’m doing something REALLY dumb!! And now I see there are problems other than the quote problem.

    single.php

    <?php $i = 1;
    $catIDs = array("23","3","4");
    foreach ($catIDs as $catID) {
    echo "loop #" . $i . "<br />";
    listGames($catID);
    echo "<br />---------<br />";
    $i++;
    } ?>

    function.php

    function listGames($catID) {
    $recent = new WP_Query();
    $recent->query( "cat=$catID" );
    while($recent->have_posts()) : $recent->the_post();
    the_title();
    echo "<br />";
    endwhile; }

    OR function.php (from Ron)

    function listGames($catID) {
    $recent = new WP_Query( array( 'cat' => $catID ) );
    while($recent->have_posts()) : $recent->the_post();
    the_title();
    echo "<br />";
    endwhile; }

    output

    loop #1
    POST FROM CAT 4
    POST FROM CAT 3
    POST FROM CAT 23
    
    ---------
    loop #2
    POST FROM CAT 3
    
    ---------
    loop #3
    POST FROM CAT 4
    POST FROM CAT 3
    
    ---------

    Forum: Hacks
    In reply to: $recent->query of cat problem
    Thread Starter rt49andellis

    (@rt49andellis)

    The double/single quote problem still happens even without the quotes on the $catID =

    And, the code actually sets the variable elsewhere. Was hoping the cut down code might help, but it just added more confusion. Here’s the real code

    function listGames($catID) {
    echo "catID is " . $catID . "<br/>"; // works
    $recent = new WP_Query();
    $recent->query("cat=$catID");
    while($recent->have_posts()) : $recent->the_post(); ?>
    .....
    Thread Starter rt49andellis

    (@rt49andellis)

    I apologize — This is posted in the wrong area. If someone could delete it, I’d appreciate it.

    New post created at this page.

    Thank you.

    Thread Starter rt49andellis

    (@rt49andellis)

    I apologize – I just realized that this portion of the profile was coming from a plugin, not the WP core.

Viewing 6 replies - 16 through 21 (of 21 total)