• Resolved thatbradguy

    (@thatbradguy)


    i’m trying to run this custom query

    <?php
    $recent = new WP_Query();
    $recent->query('category_name=video&showposts=1');
    while($recent->have_posts()) : $recent->the_post();?>
    <div><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
    <?php endwhile; ?>

    no matter what i change the value of showposts too, it still returns all there are.

    there’s no standard loop on the page. this is at the very top of the page. it’s the first wp_query() called, however i’m having the same problem on all the wp_wuery() calls that follow..

    thanks.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter thatbradguy

    (@thatbradguy)

    not helpful.

    Hmm, your query doesn’t work for me either, and don’t understand why not, but if I change that one statement and use the cat=10 (category id) instead of category_name=video, it works.

    $recent->query('cat=10&showposts=1');
    Thread Starter thatbradguy

    (@thatbradguy)

    weird. that doesn’t fix it for me.

    Thread Starter thatbradguy

    (@thatbradguy)

    this doesn’t work either:

    <?php
     global $post;
     $carouselposts = get_posts('numberposts=1&category=3');
     foreach($carouselposts as $post) :
     ?>
        <div><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
     <?php endforeach; ?>

    category_name does expect the name (and not the Slug).. iirc .. it could be the difference..

    When using the ID, it’s..

    cat=x

    not..

    category=x

    ..as per the code michael posted..

    Thread Starter thatbradguy

    (@thatbradguy)

    i was using get_posts() and its reference page indicates ‘category=1’ is correct. just for kicks i tried ‘cat=1’ it doesn’t work.

    What about not using the $recent->query?:

    <?php $recent = new WP_Query() ('cat=10&showposts=1'); while($recent->have_posts()) : $recent->the_post();?><div><a href="<?php the_permalink();?>"><?php the_title(); ?></a></div><?php endwhile; ?>

    Strange… both

    $recent->query('category_name=cat2&showposts=2');

    and

    $recent->query('category=cat2&showposts=2');

    work for me no matter what value I put into the showposts. Perhaps you’ve got to have something in a theme or a plugin that is messing this up, or perhaps your tables are in need of repair? Sorry, not very helpful but that’s the best I’ve got.

    Thread Starter thatbradguy

    (@thatbradguy)

    jeeze!

    this is an issue with the theme i’m using, carrington jam 1.0.

    here’s hoping they get it fixed soon.

    Well, that’s the underlying query problem; it’s a screwed up theme:

    “The Carrington Blog theme is intended to be a friendly theme for end-users. However some of that friendliness was also adding various complexities that made it more difficult to see exactly how the framework functions.”

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘custom query issue’ is closed to new replies.