• Resolved ayok

    (@ayok)


    Hi, I’m new to WP. I have problem to show looping post from a category.
    Here is the codes

    <ul id="sliderContent">
    <?php
    $my_query = new WP_Query('showposts=18&category_name=slides');
    if ( $my_query->have_posts() ) : while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID;
    $thumb = get_post_meta($post->ID, 'thumb-large', true);
    ?>
    <li class="sliderImage">
    <img src="<?php echo $thumb; ?>" alt="<?php the_title() ?>" />									</li>
    <?php endwhile; ?>
    <?php endif; ?>
    </ul>

    This codes return empty. I’ve looked on WP tutorials on the internet, this code has no problem. But why are there no images. $my_query->have_posts() returns just empty.

    The owner said it was working before.
    Could someone tell me what’s happened?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Michael

    (@alchymyth)

    This codes return empty

    just on the screen, or even in the html of the page?
    i.e. do you just get the ul tags?

    <ul id="sliderContent">
    </ul>

    – does the category ‘slides’ exist and have posts?
    i.e. can you get to the normal category archive of ‘slides’ and get all the posts?

    – does the query work if you use the ‘slides’ category ID with the corresponding code? example: ('showposts=18&cat=231')

    Thread Starter ayok

    (@ayok)

    Hi alchymyth.
    I just got the solution from the template maker, simplefolio.

    $category = sf_get_category_id(get_option('sf_portfolio_category'));
    $slide_count = (get_option('sf_slider_slides')) ? get_option('sf_slider_slides') : 18;
    $text_count = (get_option('sf_slider_chars')) ? get_option('sf_slider_chars') : 100;
    
    $my_query = new WP_Query('showposts='.$slide_count.'&cat='.$category);

    Thanks for the fast reply.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘have_posts() is empty’ is closed to new replies.