Adding a link in the WordPress tagline

Howdy developer!

The following is a quick and easy way to add a link in your tagline in the Customizr theme.

We are going to use the ‘tc_tagline_display’ filter to do so. (check how to locate a filter in Customizr)

Copy and paste the following code in the functions.php file of your child theme :

add_filter( 'tc_tagline_display' , 'my_link_in_tagline');

function my_link_in_tagline() {
	global $wp_current_filter;
	?>
		<?php if ( !in_array( '__navbar' , $wp_current_filter ) )  :?>
			<div class="container outside">
		        <h2 class="site-description">
		        	<?php bloginfo( 'description' ); ?>
		        	<a href="[PUT YOUR URL HERE]" title="[A TITLE]">My link</a>
		        </h2>

		    </div>
		<?php else : //when hooked on __navbar ?>
			<h2 class="span7 inside site-description">
	            <?php bloginfo( 'description' ); ?>
	            <a href="[PUT YOUR URL HERE]" title="[A TITLE]">My link</a>
	        </h2>

		<?php endif; ?>
	<?php
}

 Note : in this filter, I use the global $wp_current_filter   to determine in which filtering context we are because the function is used in two different action hook : responsive or not. Another way to check the current filter in WordPress is to use the current_filter()  function, but this one will only show the current hook and not the nested hooks (meaning hooks included in other hooks).

27 thoughts on “Adding a link in the WordPress tagline”

Comments are closed.