Forums

[resolved] need help with current_page_item (8 posts)

  1. rahendz
    Member
    Posted 8 months ago #

    howdy.. guys, can any of you help to find a way clear this up?

    i found a dead end of highlighting menu..

    current_page_item seems not working properly when i using

    random post in the sidebar.. i've noticed from when i remove the

    query_post(array('orderby'=>'rand')); from the sidebar

    the current_page_item works fine.. but when i put it back

    the current_page_item not working as usual.. please help me..

  2. esmi
    Theme Diva & Forum Moderator
    Posted 8 months ago #

    Don't use query_posts for a secondary Loop. Use get_posts or WP_Query instead.

  3. rahendz
    Member
    Posted 8 months ago #

    thanks, i'll try..

  4. rahendz
    Member
    Posted 8 months ago #

    @esmi::

    can you re-check my code..

    my random posts get error :)

    <?php
    
    $args = array('orderby'=>'rand','numberposts'=>SHOWRAND);
    
    $randomposts = get_posts($args); $load = 0;
    
    foreach( $randomposts as $post ): ?>
    
    <a href="<?php the_permalink(); ?>"><?php post_thumbnail(); ?></a>
    
    <?php
    
    endforeach; ?>

    didnt error actually, but my random post not produce

    random post with random content.. just with one content

    looped for 7 times.. thanks before.. :)

  5. rahendz
    Member
    Posted 8 months ago #

    for note.. i create random post not for content section, but for sidebar :)

  6. esmi
    Theme Diva & Forum Moderator
    Posted 8 months ago #

  7. rahendz
    Member
    Posted 8 months ago #

    it's just Constant value.. the loop is right but not the content that looped, only one post is looped..

  8. rahendz
    Member
    Posted 8 months ago #

    i still cant use the get_posts function.. but now i prefer use WP_Query function :) and it works fine.. for now.. thanks before..

Reply

You must log in to post.

About this Topic