Last active
January 5, 2018 19:00
-
-
Save digisavvy/d16b056d6c0665600d1e06b4f62dd7c0 to your computer and use it in GitHub Desktop.
Simple Beaver Builder Custom Post Property/Custom Field example. This example simply generates the permalink for the current post.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Get the external link for each post, crate a new connection for custom post template | |
| * The add_action will setup the post property so that it is selectable within Beaver Builder. | |
| * The function will grab and assign the value to the post property. | |
| * This example simple gets the current post permalink and returns/prints to screen. | |
| */ | |
| add_action( 'fl_page_data_add_properties', function() { | |
| FLPageData::add_post_property( 'll_permalink', array( | |
| 'label' => 'Post Permalink', | |
| 'group' => 'posts', | |
| 'type' => 'html', | |
| 'getter' => 'permalink_connection_getter', | |
| ) ); | |
| } ); | |
| function permalink_connection_getter() { | |
| global $post; | |
| $post_id = $post->ID; | |
| $post_slug=$post->post_name; | |
| $url = get_permalink( $post_id ); | |
| $slug = $url; | |
| return $slug; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment