random links in sidebar (5 posts)

  1. hristov
    Posted 10 years ago #

    i've checked the forum and the manual and can't find what should be a simple solution to this problem:

    in my sidebar i've used the default code (get_links('-1', etc) to list links. however, as i intend to have a lot of links i want to only display 10. i want these 10 to be randomly selected from all links.

    can anyone suggest how this could be done (with the code if possible)?

    thanks in advance.

  2. moshu
    Posted 10 years ago #

    Everything is there in the Codex:

    <?php get_links(category, 'before', 'after', 'between', show_images, 'order', show_description, show_rating, limit, show_updated, echo); ?>

    meaning you have to set the 6th parameter to 'rand' and the 9th parameter to 10.
    <?php get_links('-1', '<li>', '</li>', '<br />', FALSE, 'rand', TRUE,
    TRUE, 10, TRUE); ?>

    Change wichever parameter you don't like.

  3. hristov
    Posted 10 years ago #

    excellent, thanks for that... i just didn't spot it!

    i've developed an additional links problem during the day. my 'links' in the sidebar is repeating on every 'page'. its fine when posts are involved, just not for wp pages. can you suggest any solution for this? url's http://www.heymanchester.com/ (click one of the 'features' on the right for the problem pages).

    thanks again.

  4. moshu
    Posted 10 years ago #

    I guess you should use some Conditional_Tags and "tell" Wp to not display if is_page (sorry, I am not a coder).

  5. hristov
    Posted 10 years ago #

    ah, i sorted it. the theme ('connections') came with the links outside sidebar.php for some reason. i removed it from the main template but page.php was of course a separate template. silly design for what is otherwise a great theme.

    thanks for your suggestion again though moshu.

Topic Closed

This topic has been closed to new replies.

About this Topic