Function and usage of get_linkobjectsbyname() in wordpress


Answers ( 1 )


    The get_linkobjectsbyname() function in WordPress is used to retrieve an array of link objects that are associated with a specific category name. This function is particularly useful when you need to display or manipulate links that are categorized under a certain name in WordPress.


    get_linkobjectsbyname( string $cat_name = "noname", string $orderby = ‘name’, int $limit = -1 ): array


    The function get_linkobjectsbyname() is designed to fetch link objects from a specified category. It's useful for displaying links that are grouped under a particular category name.

    Usage Example:

    Here's a basic usage example where we fetch links from a category named 'fred':

    $links = get_linkobjectsbyname( 'fred' );
    foreach ( $links as $link ) {
        echo '<a href="' . $link->link_url . '">' . $link->link_name . '</a><br>';

    This snippet will output HTML links for each link in the 'fred' category.


    1. $cat_name (string, optional): The name of the category. If no matching category is found, links from all categories are returned. Default value is 'noname'.
    2. $orderby (string, optional): Defines the order in which the links are returned. Possible values include 'id', 'name', 'url', 'description', 'rating', or 'owner'. You can prefix these with an underscore to reverse the order. Additionally, 'rand' can be used for a random order. The default is 'name'.
    3. $limit (int, optional): Limits the number of returned entries. A negative number implies no limit. The default is -1, which means all entries are shown.


    • array: The function returns an array of link objects corresponding to the specified category.

    See Also:

    • get_bookmarks(): This is another WordPress function used for retrieving bookmarks or links, offering more customization options.


    • It's essential to ensure that the category name provided matches the actual category name used in WordPress.
    • The function is useful for theme developers or plugin authors who need to list links based on categories.
    • The function is part of WordPress's Link Manager, which might not be enabled in newer versions of WordPress by default.

Leave an answer