The get_links_withrating() WordPress PHP function retrieves the links associated with a specified category and displays their rating stars/chars.
Usage
get_links_withrating($category = 0, $before = '', $after = '<br />', $between = ' ', $show_images = true, $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0);
Parameters
$category
(int) Optional: The category to use. If no category supplied, uses all. Default: 0$before
(string) Optional: The HTML to output before the link. Default: ”$after
(string) Optional: The HTML to output after the link. Default:<br />
$between
(string) Optional: The HTML to output between the link/image and its description. Not used if no image or$show_images
is true. Default: ‘ ‘$show_images
(bool) Optional: Whether to show images (if defined). Default: true$orderby
(string) Optional: The order to output the links. E.g. ‘id’, ‘name’, ‘url’, ‘description’, ‘rating’, or ‘owner’. Default ‘id’. If you start the name with an underscore, the order will be reversed. Specifying ‘rand’ as the order will return links in a random order. Default: ‘id’$show_description
(bool) Optional: Whether to show the description if$show_images
is false/not defined. Default: true$limit
(int) Optional: Limit to X entries. If not specified, all entries are shown. Default: -1$show_updated
(int) Optional: Whether to show the last updated timestamp. Default: 0
More information
See WordPress Developer Resources: get_links_withrating()
Examples
Display all links
This example retrieves all links and displays them with their respective ratings.
get_links_withrating();
Display links from a specific category
This example retrieves links from category 5 and displays them with their respective ratings.
get_links_withrating(5);
Display links without images
This example retrieves all links and displays them without images, showing only their respective ratings.
get_links_withrating(0, '', '<br />', ' ', false);
Display links ordered by name
This example retrieves all links and displays them ordered by name with their respective ratings.
get_links_withrating(0, '', '<br />', ' ', true, 'name');
Limit the number of displayed links
This example retrieves and displays the first 3 links with their respective ratings.
get_links_withrating(0, '', '<br />', ' ', true, 'id', true, 3);