ThemeShaper Forums » Thematic

[closed]

Removing text "Category Archives:" but leaving category name

(7 posts)
  • Started 2 years ago by onelittlemoose
  • Latest reply from onelittlemoose
  • This topic is resolved
  1. onelittlemoose
    Member

    I'm trying to remove the words "Category Archives:" from the top of my page, right above the part where it lists the posts in that category. Important to note that I still want the actual name of the category to appear, I just don't want those 2 words "Category Archives:" there.

    Here is what I have tried. It does not throw an error, but it does not work:

    function childtheme_override_categoryarchive($content) {
    	$content = '<h1 class="page-title">';
    	$content .= __('', 'thematic');
    	$content .= ' <span>';
    	$content .= single_cat_title('', FALSE);
    	$content .= '</span></h1>' . "\n";
    	$content .= '<div class="archive-meta">';
    
    	return apply_filters('thematic_categoryarchive',$content);
    }

    And so now you know that I'm so new at this I still have the pricetag attached to my toe...

    Any help is welcome. Thanks.

    Posted 2 years ago #
  2. A override will basically kill whatever else was in there and you completely redo it. So if you want to only mess with the "Categories" and leave all your other page titles alone, you will want to filter it.

    Try.

    function snix_thematic_page_title($content) {
    		 if (is_category()) {
    				$content .= '<h1 class="page-title">';
    				$content .= __('Change Me:', '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', 'snix_thematic_page_title', $content);

    Didn't test this one, but I think it should work. So be sure to make sure it didn't modify other page titles also.

    For an override, you would want to paste almost everything from thematic_page_title in the thematic/library/extensions/content-extensions.php since there are a lot of different options for titles in there, some involving best practices for SEO (except for html5, but you don't have that option). ;P

    Posted 2 years ago #
  3. onelittlemoose
    Member

    Many thanks. I have tried it, and while it does work, it actually added 2 page titles. The first is the "Category Archives: [my category name]", and below it, just "[my category name]".

    What's also interesting, is that I had first tried this tutorial here:
    http://alittletheme.com/category-page-remove-category-archive-from-page-title/
    but it gave me errors. Comparing to yours, I think the problem was some character conversions in the quotation marks. Once I fixed that, no errors. However, I also see a difference in $content = '<h1 class="page-title">’; vs yours $content .= '<h1 class="page-title">'; (they also did not include the $content at the very end)

    Thinking that the . might be the source of the repeat, I took it out of your code. No repeat, but the "Category Archives:" remains. Modifying the other person's code to the following,

    function alittle_page_title_filter($content) {
    if (is_category()) {
    	$content .= '<h1 class="page-title">';
    	$content .= __('', ‘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’, ‘alittle_page_title_filter’, $content);

    Doesn't throw errors anymore, but also doesn't achieve the desired result. Strangely, it also doesn't repeat the page title.
    I'm baffled.

    Posted 2 years ago #
  4. This should work.

    It was a combo of 2 things, I should have tested it. ;x

    function snix_thematic_page_title($content) {
    	if (is_category()) {
    		$content = '<h1 class="page-title">';
    		$content .= __('Change Me:', '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', 'snix_thematic_page_title');
    Posted 2 years ago #
  5. onelittlemoose
    Member

    Wow, that is amazing, thank you. By not testing it, you gave me a learning opportunity :) I see the difference, no "." before the "=" in the
    $content = '<h1 class="page-title">';

    The "." as I understand it has an additive purpose.

    Interesting, I went thru the other person's code line by line, and other than the character conversions with the quotation marks, I can't see any reason why theirs shouldn't work, yet it refuses to work.

    Thanks again! I can now move forward with the other things on the list to change ...

    Posted 2 years ago #
  6. The link you posted with the code probably does technically work.

    See the [PHP] at the top and the closing one at the bottom, normally a plugin would grab those and Convert Raw HTML to Escaped HTML and style it fancy.

    Well when that plugin isn't on, Wordpress will mangle the code, so WordPress changes a standard apostraphe (used in code) to an apostrophe which won't work (the little angled ones).

    if you just redid them all the ' it would probably work. :P

    Posted 2 years ago #
  7. onelittlemoose
    Member

    I think I see what you mean. Thanks.

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.