I have enabled the built-in Link Manager for WordPress, which was previous enabled by default in WordPress (https://codex.wordpress.org/Links_Manager).
Now it seems like it handles link and link categories like any other taxonomy and post. Therefore it shoueld be possible to create the link in the manager, and then choose it from a relational custom field. This way it is much easier to manage a large portion of external links and re-use them.
I have tried the field type Taxanomy, Post Object, etc. but in none of them do I get the option to choose links.
Can anyone help here?
I don’t know how WP handles these, but the links are not listed in the global $wp_post_types. ACF uses get_post_types() for the location options. It also appears that after a quick look that WP handles these in a way that’s completely different that other post types, if they are a post type. I’m going to say that they are not a post type because they are stored in their own DB table, and not in the wp_posts table.
This has been disabled for a long time in WP. You should probably look what you want in some other way if you want to add custom fields using ACF.
Thanks for your answer.
Yes you are right, the links are stored in their own tabel. But the relationship, term etc. is the same as with other post types. Only they refer to the link table instead of post table. Do you think it is an impossible task?
Do you have some suggestions on other ways I attach links to posts and manage them from one place? 🙂
The editor used on for these in WP is not the same editor as a post or a term, or any of the other types of admin pages that ACF detects and adds fields to. To be honest, I’m not certain that ACF can even detect the admin pages or add custom field groups to them.
ACF basically adds meta boxes using the standard add_meta_box() function of WP https://developer.wordpress.org/reference/functions/add_meta_box/. If this is used on the link editor then ACF may be able to add custom fields. I don’t know how these pages work, I have not seen them used since they were disabled by default. If these pages do work in a similar way then you’d have to add custom location rules.
The next hurdle would be where “meta” for these would be stored. There is not meta table for them and ACF wouldn’t know how to store or retrieve the values. Now that I think about it, this probably means that it is impossible do to this using ACF since there isn’t an ID of any kind that you can use to tell ACF to get values associated with a link.
Since this is not really a supported feature in WP, except for backwards compatibility if the site used them in the past there’s very little chance that the developer of ACF is going to devote a lot making ACF work with them.
I would start by creating a custom post type and building the admin I want for the cpt using ACF. Then you need to figure out how you want to relate these to a post. I really don’t know how you’d do this. I think I built one site years ago that uses the links in WP.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2023 Advanced Custom Fields.