Throughout our site, I'd like to use a function to print the href
of an anchor tag. The function parses query params and properly translates them on to a link to another site.
In functions.php
, I've added:
add_filter( 'main_site_url', 'return_main_site_url' );
function return_main_site_url( $default_source = '' ) {
$main_site_url = "https://www.example.com";
if ( get_query_var('ws') ) {
$main_site_url .= '?s=';
$main_site_url .= get_query_var('ws');
} elseif ( !empty($default_source) ) {
$main_site_url .= '?s=';
$main_site_url .= $default_source;
}
return $main_site_url;
}
I've tried to use the function from an HTML Contact widget in the sidebar like:
<a href="<?php echo apply_filters('main_site_url', wp_sidebar') $>" class="btn btn-danger">Learn More</a>
The output ends up NOT being processed:
<a href="<?php echo apply_filters('main_site_url', 'wp_sidebar') ?>" class="btn btn-danger">Learn More</a>
How do you go about using a function from an HTML widget on the sidebar?