Skip to content

Adds a ACF field that allows selecting posts across the network sites.

License

Notifications You must be signed in to change notification settings

timiwahalahti/acf-field-network-post-select

Repository files navigation

Advanced Custom Fields: Network posts select field

GitHub release (latest SemVer) Tested_up_to WordPress_5.5 Compatible_with AFC_5 GitHub

Adds a ACF field that allows selecting posts across the network sites.

Screenshot 2020-10-01 at 21.43.59

The field is very much silimar to native ACF Post Object one, with the exception that network posts select field will allow users to search posts across the entire network rather than just the site in which dashboard they are. On field settings it's possible to confugure a list of allowed sites in network from which the posts can be selected.

Because you don't do much with post ID or object if it's for wrong site in a network, the field returns always an array that contains site_id and post_id. Then you, as a developer, can use these ID's however you like.

Screenshot 2020-10-01 at 21.42.06

Note about large networks

It's highly suggested to use site filter if your network has tens of sites.

Field works, but search gets slower as the number of sites in network increases. This is something I might try to enhance in future. If your network has over 100 sites, field will try to get posts only from the first 100 sites. To change this, use acf/fields/network_post_select/settings/max_sites filter to tell how many sites are shown in field options.

In case you like to live dangerously, there's also acf/fields/network_post_select/result filter available where you can change arguments for get_sites function used in posts search.

Changelog

Changelog can be found from releases page and separate CHANGELOG.md file. The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Contributing

Code contributions, feedback, and feature suggestions are very welcome.