Skip to content

Instantly share code, notes, and snippets.

@ninjamonkno1
Created August 6, 2017 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ninjamonkno1/3af7f216a1faa09052814b359ec8bacf to your computer and use it in GitHub Desktop.
Save ninjamonkno1/3af7f216a1faa09052814b359ec8bacf to your computer and use it in GitHub Desktop.
Get Permalink or post id in beaver builder Custom Post Layouts
<?php
add_action( 'fl_page_data_add_properties', function() {
FLPageData::add_post_property( 'permalink', array(
'label' => 'Post Permalink',
'group' => 'posts',
'type' => 'string',
'getter' => 'permalink_getter',
) );
} );
function permalink_getter() {
global $post;
return get_permalink($post->ID);
}
add_action( 'fl_page_data_add_properties', function() {
FLPageData::add_post_property( 'post_id', array(
'label' => 'Post ID',
'group' => 'posts',
'type' => 'string',
'getter' => 'id_getter',
) );
} );
function id_getter() {
global $post;
return $post->ID;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment