Skip to content
Controls

URL

URL control provides a link input field with post/page search functionality. Users can enter custom URLs or search and select from existing WordPress content.

URL Control

The control supports searching through your site's content - just start typing the post or page name:

URL control with post search

Control Settings

  • Link Suggestions - Choose which content types appear in search results
  • Show Initial Suggestions - Display suggestions immediately on focus
  • Rich Preview - Show link preview with site title and image

Usage Examples

PHP
<?php if ( $attributes['control_name'] ) : ?>
    <a href="<?php echo esc_url( $attributes['control_name'] ); ?>"
       class="button">
        Visit Link
    </a>
<?php endif; ?>
Handlebars
{{#if control_name}}
  <a href="{{control_name}}" class="button">
    Visit Link
  </a>
{{/if}}
PHP
<?php
$url = $attributes['control_name'];
if ( $url ) : ?>
    <div class="cta-button">
        <a href="<?php echo esc_url( $url ); ?>"
           class="button"
           target="_blank"
           rel="noopener noreferrer">
            Learn More
        </a>
    </div>
<?php endif; ?>

Post Meta

Post Meta
<?php
$url = get_lzb_meta( 'control_meta_name' );
if ( $url ) {
    echo '<div class="link-wrapper">';
    printf(
        '<a href="%1$s" class="button">%2$s</a>',
        esc_url( $url ),
        esc_html__( 'Read More', 'your-text-domain' )
    );
    echo '</div>';
}
?>
  • Always use esc_url() when outputting URLs to prevent XSS attacks.
  • Consider adding target="_blank" and rel="noopener noreferrer" for external links.

Was this article helpful?