Title: getting link category
Last modified: August 18, 2016

---

# getting link category

 *  [jcarlile](https://wordpress.org/support/users/jcarlile/)
 * (@jcarlile)
 * [18 years, 8 months ago](https://wordpress.org/support/topic/getting-link-category/)
 * I am a total php newbie, and I am trying to modify this script
    [http://infovore.org/src/getrandomlinks.phps](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

The topic ‘getting link category’ is closed to new replies.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)

 * 0 replies
 * 1 participant
 * Last reply from: [jcarlile](https://wordpress.org/support/users/jcarlile/)
 * Last activity: [18 years, 8 months ago](https://wordpress.org/support/topic/getting-link-category/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
