Advanced Custom Fields: Smart Button
A simple, clean and lean acf Field for internal and external links.
by Gilles Goetsch · github.com/gillesgoetsch/acf-smart-button · website
★ 76stars
26kcomposer installs
15forks
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/gillesgoetsch/acf-smart-button/archive/refs/heads/master.zipAlso on Packagist as gillesgoetsch/acf-smart-button:
composer require gillesgoetsch/acf-smart-buttonFrom the readme
ACF Smart Button
A simple, clean and lean ACF Field that allows the user to select an internal link as a postobject or an external link as a url field via a smooth toggle.
It always returns the url as the same field, whether it's an internal or external link. With button.target you can additionally add target="blank" in your template without additional casing.
Example (twig style):
Isn't that lean =)?
Example (vanilla PHP):
Output / Return
When Internal
[text] = I am an internal button
[url] = http://yoursite.dev/selected-page
[target] = ''
When External
[text] = I am an external button
[url] = http://kollektiv.ag
[target] = 'target="blank"'
Note: In both cases the field data will only be returned if the button text is set in combination with a target. If either one is missing, there will be no data returned.
Future Plans
- ~~option to select allowed posttypes for postobject selector~~ 7626ad4
- language support
- validate url field
- cleanups etc.
- ~~eventually acf4 support~~ (no?)
Compatibility
This add-on works only with version 5 and up.
Installation
This add-on can be treated as both a WP plugin and a theme include.
Install as Plugin
1. Copy the '
Read the full README on GitHub →