Skip to content

Instantly share code, notes, and snippets.

@wpexplorer
Created April 20, 2023 21:30
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 wpexplorer/a32235fd5286b11ab0323b84363959d6 to your computer and use it in GitHub Desktop.
Save wpexplorer/a32235fd5286b11ab0323b84363959d6 to your computer and use it in GitHub Desktop.
WPBakery column links.
// Add link option to columns.
add_action( 'vc_after_init', function() {
vc_add_param( 'vc_column', array(
'type' => 'textfield',
'param_name' => 'link',
'heading' => esc_html__( 'Link', 'total'),
) );
} );
// Insert link into columns.
add_filter( 'wpex_hook_vc_column_inner_top', function( string $content, array $atts ) {
// Don't add links in the front-end editor as this can break things.
if ( function_exists( 'vc_is_inline' ) && vc_is_inline() ) {
return $content;
}
// Insert link.
if ( ! empty( $atts['link'] ) ) {
$link_safe = esc_url( $atts['link'] );
$content .= "<a href='{$link_safe}' class='wpex-absolute wpex-block wpex-inset-0'></a>";
}
// Return hook content.
return $content;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment