ThemeShaper Forums » Thematic

[closed]

Changing page-title contents using functions.php

(4 posts)
  • Started 11 years ago by linup
  • Latest reply from linup
  • This topic is not resolved
  1. linup
    Member

    Hi there-
    Loving this framework, but am new to any development & need some guidance as to how to change things using filters & action hooks....
    For example, I need to get rid of the words "category archives" on my cat archives pages. These are default in the "page-title."
    I found the related code in content-extensions.php file (library > extensions folder). See below. I know I have to make this happen in my functions.php file in my child theme... but I am not clear on what to write in the functions.php code to get rid of the words, Category Archives.
    Would someone be so kind as to walk me through this?
    Thanks in advance... and thanks for this time-saving gem of a theme!
    Lindsay

    Code from content-extensions.php
    // Filter the page title
    
    // located in archive.php, attachement.php, author.php, category.php, search.php, tag.php
    
    if (function_exists('childtheme_override_page_title'))  {
    
    	function thematic_page_title() {
    
    		childtheme_override_page_title();
    
    	}
    
    } elseif (is_category()) {
    
    				$content .= '<h1 class="page-title">';
    
    				$content .= __('Category Archives:', 'thematic');
    
    				$content .= ' <span>';
    
    				$content .= single_cat_title('', FALSE);
    
    				$content .= '</span></h1>' . "\n";
    
    				$content .= '<div class="archive-meta">';
    
    				if ( !(''== category_description()) ) : $content .= apply_filters('archive_meta', category_description()); endif;
    
    				$content .= '</div>';
    Posted 11 years ago #
  2. I wouldn't be the one to walk you through as there are a bunch of different details, but this is just an easy filter.

    function childtheme_page_title($content) {
    	if (is_category()) {
    		$content = '<h1 class="page-title">';
    		$content .= __('Custom Text or Remove:', 'thematic');
    		$content .= ' <span>';
    		$content .= single_cat_title('', FALSE);
    		$content .= '</span></h1>' . "\n";
    		$content .= '<div class="archive-meta">';
    		if ( !(''== category_description()) ) : $content .= apply_filters('archive_meta', category_description()); endif;
    		$content .= '</div>';
    	}
    	return $content;
    }
    add_filter('thematic_page_title','childtheme_page_title');

    It will now output "Custom Text or Remove:", you can just remove or change the text there.

    If you were doing a bunch of modifications to all your page titles, you would probably want to then use an override. To override, it looks like this.

    function childtheme_override_page_title() {
    	global $post;
    
    	$content = '';
    	if (is_attachment()) {
    			$content .= '<h2 class="page-title"><a href="';
    			$content .= apply_filters('the_permalink',get_permalink($post->post_parent));
    			$content .= '" rev="attachment"><span class="meta-nav">&laquo; </span>';
    			$content .= get_the_title($post->post_parent);
    			$content .= '</a></h2>';
    	} elseif (is_author()) {
    			$content .= '<h1 class="page-title author">';
    			$author = get_the_author_meta( 'display_name' );
    			$content .= __('Author Archives: ', 'thematic');
    			$content .= '<span>';
    			$content .= $author;
    			$content .= '</span></h1>';
    	} elseif (is_category()) {
    			$content .= '<h1 class="page-title">';
    			$content .= __('Category Archives:', 'thematic');
    			$content .= ' <span>';
    			$content .= single_cat_title('', FALSE);
    			$content .= '</span></h1>' . "\n";
    			$content .= '<div class="archive-meta">';
    			if ( !(''== category_description()) ) : $content .= apply_filters('archive_meta', category_description()); endif;
    			$content .= '</div>';
    	} elseif (is_search()) {
    			$content .= '<h1 class="page-title">';
    			$content .= __('Search Results for:', 'thematic');
    			$content .= ' <span id="search-terms">';
    			$content .= esc_html(stripslashes($_GET['s']));
    			$content .= '</span></h1>';
    	} elseif (is_tag()) {
    			$content .= '<h1 class="page-title">';
    			$content .= __('Tag Archives:', 'thematic');
    			$content .= ' <span>';
    			$content .= __(thematic_tag_query());
    			$content .= '</span></h1>';
    	} elseif (is_tax()) {
    			global $taxonomy;
    			$content .= '<h1 class="page-title">';
    			$tax = get_taxonomy($taxonomy);
    			$content .= $tax->labels->name . ' ';
    			$content .= __('Archives:', 'thematic');
    			$content .= ' <span>';
    			$content .= thematic_get_term_name();
    			$content .= '</span></h1>';
    	}	elseif (is_day()) {
    			$content .= '<h1 class="page-title">';
    			$content .= sprintf(__('Daily Archives: <span>%s</span>', 'thematic'), get_the_time(get_option('date_format')));
    			$content .= '</h1>';
    	} elseif (is_month()) {
    			$content .= '<h1 class="page-title">';
    			$content .= sprintf(__('Monthly Archives: <span>%s</span>', 'thematic'), get_the_time('F Y'));
    			$content .= '</h1>';
    	} elseif (is_year()) {
    			$content .= '<h1 class="page-title">';
    			$content .= sprintf(__('Yearly Archives: <span>%s</span>', 'thematic'), get_the_time('Y'));
    			$content .= '</h1>';
    	} elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {
    			$content .= '<h1 class="page-title">';
    			$content .= __('Blog Archives', 'thematic');
    			$content .= '</h1>';
    	}
    	$content .= "\n";
    	echo apply_filters('thematic_page_title', $content);
    }
    Posted 11 years ago #
  3. linup
    Member

    Thanks ScottNix & helgatheviking for the tips!

    Posted 11 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.