Custom Dynamic Title For Backbone Theme

dynamic title is a default title structure that will be displayed on your archive page. It can be a search result archive, category archive, etc.

Untitled

There is no default structure for the dynamic title, it is depend on the theme vendor where you got your theme. For example ColorLabs, if you check their dynamic title they are following the default from TwentyEvelen WordPress theme.

For some people, these default title text is too weird and they want to change it by their own. Then a new problem came, not all people who use WordPress theme is a programmer or know about PHP coding.

At this post i want to share how to make a custom theme options that will help you to change these dynamic title on Backbone theme easily. After these modifications, you are no longer have to modify the theme files.

Step#1

At this first step you have to modify a file named theme-options.php. You can find out this file via FTP at directory: wp-content > themes > backbone > includes.

At this file you have to add a new options that will help you to type your custom dynamic title. Open the file and find out this code:

/* //Social Settings	 */				
$options[] = array( "name" => __("Social Networking", "colabsthemes" ),
					"icon" => "misc",
					"type" => "heading");

Once you find out that code, put this code above that:

// Dynamic Titles
$options[] = array( "name" => __("Custom Dynamic Titles", "colabsthemes" ),
					"type" => "heading",
					"icon" => "general");
					
$options[] = array( "name" => "Set Custom Text Position",
					"desc" => "You can set where does these custom texts will be displayed. <b>Activate this option</b> if you want to set these texts displayed <b>before</b> the <b>category name</b>. Turn this option off will make these texts displayed <b>after</b> the category name.",
					"id" => $shortname."_disable_dynamic",
					"std" => "false",
					"type" => "checkbox");					
					

$options[] = array( "name" => __( "Archive by Author Title", "colabsthemes" ),
					"desc" => __( "Type your custom title for Archive by Author", "colabsthemes" ),
					"id" => $shortname."_dynamic_author",
					"std" => "",
					"type" => "text"); 				

$options[] = array( "name" => __( "Archive by Category Title", "colabsthemes" ),
					"desc" => __( "Type your custom title for Archive by Category", "colabsthemes" ),
					"id" => $shortname."_dynamic_category",
					"std" => "",
					"type" => "text"); 							
					
$options[] = array( "name" => __( "Archive by Tag Title", "colabsthemes" ),
					"desc" => __( "Type your custom title for Archive by Tag", "colabsthemes" ),
					"id" => $shortname."_dynamic_tag",
					"std" => "",
					"type" => "text"); 				

$options[] = array( "name" => __( "Default Archive Title", "colabsthemes" ),
					"desc" => __( "Type your custom title for Default Archive", "colabsthemes" ),
					"id" => $shortname."_dynamic_default",
					"std" => "",
					"type" => "text"); 									
					
$options[] = array( "name" => __( "Search Archive Title", "colabsthemes" ),
					"desc" => __( "Type your custom title for Archive by Search Result", "colabsthemes" ),
					"id" => $shortname."_dynamic_search",
					"std" => "",
					"type" => "text"); 				

Once you done with it, you can check your Backbone dashboard and you will find a new theme option named custom dynamic titles.

Here is some explanation about that code:

  • The check box option prepared to give you an option whether you want to put these custom title before or after the object title (category/tag/search query). If the check box is ticked (active), then these custom text will be displayed before the object title. Vice versa if you are not ticking the check box

Step#2

At this second step, you have to modify a file named theme-functions.php. At this file you have to change the default dynamic title with the one you just made.

You can find out this file via FTP at directory: wp-content > themes > backbone > includes. Open the file and find out this code:

/*-----------------------------------------------------------------------------------*/
/* Dynamic Titles */
/*-----------------------------------------------------------------------------------*/
// This sets your <title> depending on what page you're on, for better formatting and for SEO

function dynamictitles($args) {

//value
$before = '';
$after = '';

if ( !is_array($args) ) 
    parse_str( $args, $args );
	
extract($args);
	
echo $before;

if ( is_single() ) {
      wp_title('');
     
} else if ( is_page() || is_paged() ) {
      
      wp_title();
 
} else if ( is_author() ) {
     
      wp_title(''.__('Author','colabsthemes').'');	  
	  
} else if ( is_category() ) {
      
      wp_title(''.__('Category for','colabsthemes').'');
      

} else if ( is_tag() ) {
      
      wp_title(''.__('Tag archive for','colabsthemes').'');

} else if ( is_archive() ) {
      
      echo (__('Archive for','colabsthemes').'');
      wp_title('');

} else if ( is_search() ) {
      
      echo (''.__('Search Results for ','colabsthemes').'');
	  echo '"';
		the_search_query();
	  echo '"';	
} else if ( is_404() ) {

Remove that codes and replace with this codes:

/*-----------------------------------------------------------------------------------*/
/* Dynamic Titles */
/*-----------------------------------------------------------------------------------*/
// This sets your <title> depending on what page you're on, for better formatting and for SEO

function dynamictitles($args) {

//value
$before = '';
$after = '';
$dynamic_status = get_option( "colabs_disable_dynamic" );


if ( !is_array($args) ) 
    parse_str( $args, $args );
	
extract($args);
	
echo $before;

if ( is_single() ) {
      wp_title('');
     
} else if ( is_page() || is_paged() ) {
      
      wp_title();
 
} else if ( is_author() ) {

			$dynamic_author= get_option( "colabs_dynamic_author" );
			
			if ($dynamic_author !='') {
				$dynamic_author = get_option( "colabs_dynamic_author" );
			}	else {
				$dynamic_author = 'Author';
			}
			
			if ($dynamic_status == 'true') {
			wp_title(''); echo ' ' . $dynamic_author;
			} else {
			echo $dynamic_author . ' '; wp_title(''); 
			}
	  
} else if ( is_category() ) {

      $dynamic_category = get_option( "colabs_dynamic_category" );
			
			if ($dynamic_category !='') {
				$dynamic_category = get_option( "colabs_dynamic_category" );
			}	else {
				$dynamic_category = 'Category for';
			}
			
			if ($dynamic_status == 'true') {
			wp_title(''); echo ' ' . $dynamic_category;
			} else {
			echo $dynamic_category . ' '; wp_title(''); 
			}
      
      

} else if ( is_tag() ) {
      
      $dynamic_tag = get_option( "colabs_dynamic_tag" );
			
			if ($dynamic_tag !='') {
				$dynamic_tag = get_option( "colabs_dynamic_tag" );
			}	else {
				$dynamic_tag = 'Tag for';
			}
			
			if ($dynamic_status == 'true') {
			wp_title(''); echo ' ' . $dynamic_tag;
			} else {
			echo $dynamic_tag . ' '; wp_title(''); 
			}

} else if ( is_archive() ) {
      
      $dynamic_default = get_option( "colabs_dynamic_default" );
			
			if ($dynamic_default !='') {
				$dynamic_default = get_option( "colabs_dynamic_default" );
			}	else {
				$dynamic_default = 'Archive for';
			}
			
			if ($dynamic_status == 'true') {
			wp_title(''); echo ' ' . $dynamic_default;
			} else {
			echo $dynamic_default . ' '; wp_title(''); 
			}

} else if ( is_search() ) {

			$dynamic_search = get_option( "colabs_dynamic_search" );
			
			if ($dynamic_search !='') {
				$dynamic_search = get_option( "colabs_dynamic_search" );
			}	else {
				$dynamic_search = 'Search Result for';
			}
			
			if ($dynamic_status == 'true') {
			the_search_query(); echo ' ' . $dynamic_search;
			} else {
			echo $dynamic_search . ' '; the_search_query(); 
			}
			
      
} else if ( is_404() ) {

And you are done!

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s