Function and usage of get_linksbyname() in wordpress


Answers ( 1 )


    The get_linksbyname() function in WordPress is designed to retrieve and display links associated with a specific category name. This function is useful for managing and displaying links or bookmarks on a WordPress site. Here's a detailed explanation of the function and its parameters:


    • Purpose: Gets the links associated with the category $cat_name.


    • This function is related to get_bookmarks(), which is another function used for fetching bookmarks in WordPress.


    1. $cat_name (string, optional):

      • Description: The category name to use for fetching links.
      • Default: 'noname'.
      • If no matching category is found, the function uses all categories.
    2. $before (string, optional):

      • Description: HTML content to output before each link.
      • Default: An empty string.
    3. $after (string, optional):

      • Description: HTML content to output after each link.
      • Default: '<br />'.
    4. $between (string, optional):

      • Description: HTML content to output between the link/image and its description. Not used if $show_images is false.
      • Default: A space (" ").
    5. $show_images (bool, optional):

      • Description: Whether to show images associated with the links (if defined).
      • Default: true.
    6. $orderby (string, optional):

      • Description: The order in which to output the links. Can be 'id', 'name', 'url', 'description', 'rating', or 'owner'. Use an underscore (_) before the name for reverse order. 'rand' for random order.
      • Default: 'id'.
    7. $show_description (bool, optional):

      • Description: Whether to show the description of the link if $show_images is false or not defined.
      • Default: true.
    8. $show_rating (bool, optional):

      • Description: Whether to show rating stars/characters for the links.
      • Default: false.
    9. $limit (int, optional):

      • Description: Limits the number of entries displayed. If not specified, all entries are shown.
      • Default: -1 (meaning no limit).
    10. $show_updated (int, optional):

    • Description: Whether to show the last updated timestamp for the links.
    • Default: 0 (not shown).

    Sample Usage:

    // Example: Display links from a category named 'Friends' with descriptions and images
    get_linksbyname('Friends', '', '<br />', ' - ', true, 'name', true, false, -1, 0);

    This example will display links from the 'Friends' category, ordered by name, showing both images and descriptions, separated by a hyphen. The links are followed by a <br /> tag. There's no limit on the number of links displayed, and the last updated timestamp is not shown.

Leave an answer