Forums

WP 2.1 - get_bookmark() doesn't work in theme code (3 posts)

  1. vertino
    Member
    Posted 5 years ago #

    For a bespoke theme (for my personal site), I want access the link (aka bookmark) data using the "get_bookmark()" function.

    I get the following error:

    Fatal error: Call to undefined function wp_get_link_cats() in .../wp-includes/bookmark.php on line 7

    From searching through the core wp code, wp_get_link_cats() is only available via the admin.

    Will this be available to the front-end? i.e. plugins and themes?

    My current workaround is to use the get_bookmarks() function... which is working well, but I'd prefer a single object rather than array collection of an object.

  2. Jeremy Boggs
    Member
    Posted 5 years ago #

    I needed the wp_get_link_cats() function on the front-end too, and I found a solution. I simply copied the wp_get_link_cats() function in admin-db.php into a plugin, renamed the function get_link_cats_front() and activated the plugin. I renamed it in case there might be a conflict. And adding it as a plugin makes it available on the front-end.

    Its worked for me so far; I haven't broken anything, but I also haven't thoroughly tested it. Has anyone else done something similar? Any problems with this approach?

  3. charismabiz
    Member
    Posted 4 years ago #

    vertino: I'm getting that error as well. I propose that someone proposes it to trac that the function be moved somewhere where it's freely accessible to both back and front.

    jeremyboggs: the problem with this is that it's a different name... thus code that should normally be calling wp_get_link_cats() is forced to be calling get_link_cats_front() instead. Not to mention that any changes to the core aren't necessarily compatible with that "fix".

Topic Closed

This topic has been closed to new replies.

About this Topic