WordPress.org

Ready to get started?Download WordPress

Forums

Query question (5 posts)

  1. FionaGilbert
    Member
    Posted 4 years ago #

    Hi all,

    I am trying to code a query so I am able to show an ajax featured post slideshow just for categories, now PHP is not my strong point and wondered if any one could review this code and tell me if I have done it correctly.

    I don't want to specify a category, I just want category generated when I click said categories hyperlink.

    This is my code: http://paste-it.net/public/s8d64b4/

    Any help greatly appreciated,

    Fiona

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    Change:
    $query1->query('&showposts=5&cat=');
    to
    $query1->query('&posts_per_page=5&cat=');

    perhaps? showposts has been deprecated in favour of posts_per_page and will (presumably) disappear in the not-too-distant-future.

    The logic and syntax seems OK to me - apart from $a seems unused.

    Edit: where's the cat id being pulled from?

  3. FionaGilbert
    Member
    Posted 4 years ago #

    Good call esmi,

    This code is being used in a category.php page.

    So really I should incorporate '<?php if (is_category()) { ?>' within the code I presume. If I'm honest I am not sure where. Could you guide me please?

    Thank you

    Fiona

  4. FionaGilbert
    Member
    Posted 4 years ago #

    Hi again,

    This is my second attempt :)

    http://paste-it.net/public/d3808bc/

    Now this works but my entries below the featured section display the same content as featured section. How do I show the next 5 entries after the featured section please?

    Thanks,
    Fiona

  5. jessn
    Member
    Posted 4 years ago #

    Try the offset option:

    <!-- Entries below the featured section -->
    <?php $c = 1; $query3 = new WP_Query();$query3->query('posts_per_page=5&offset=5&cat=' . get_query_var('cat')); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags