WordPress.org

Ready to get started?Download WordPress

Forums

getting link category (1 post)

  1. jcarlile
    Member
    Posted 6 years ago #

    I am a total php newbie, and I am trying to modify this script
    http://infovore.org/src/getrandomlinks.phps

    so that the function takes an additional parameter, which is the category id from which to choose links.

    I am able to add the new parameter, but I'm having a hard time getting at the category id of the chosen link

    I modified the line
    $results = $wpdb->get_results("SELECT link_url, link_name, link_description FROM $wpdb->links WHERE link_visible = 'Y' ORDER BY rand() LIMIT ".$number);

    to read
    $results = $wpdb->get_results("SELECT link_url, link_name, link_description FROM $wpdb->links WHERE link_visible = 'Y' AND link_category = $link_cat ORDER BY rand() LIMIT ".$number);

    but now the script fails, so I'm obviously doing something wrong with link_category. Any ideas what am I doing wrong?

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags