ThemeShaper Forums » Thematic

[closed]

Changing page title on category pages

(10 posts)
  • Started 4 years ago by erikvlie
  • Latest reply from Gigi
  • This topic is not resolved
  1. Somewhere on these forums I read it's easy to override code using childtheme_override statements that you just copy from the theme's functions.php and then adjust as needed.

    That is what I tried with the below code and it doesn't work. For absolute beginners like myself who also are really stupid when it comes to scripting and programming, there should really be a more elaborate documentation IMMHO...

    function childtheme_override_page_title()  {
    		global $post;
    		$content = '';
    		if (is_category()) {
    				$content .= '<h1 class="page-title">';
    				$content .= __('Classification:', '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());
    				$content .= '</div>';
    }
    		$content .= "\n";
    		echo apply_filters('thematic_page_title', $content);
    }
    add_action('thematic_page_title','childtheme_override_page_title');
    Posted 4 years ago #
  2. i get frustrated alot too. I've spent 8 hours trying to make things work, only to discover the code was fine...i just missed a ) somewhere...

    Unfortunately, free means get what you can get. Hybrid is free, but because Justin uses a pay-for-support model, he can afford to develop more indepth documentation. Thematic is completely free, maintained and supported by volunteers.

    I totally feel where you're coming from, but, its kind of like looking on the side of the road, seeing alot of litter, and saying, man, this place is a dump, somebody should clean this mess up.

    Finally, seriously. Based on the things I see you trying to do, I think you should download a good stock of the free thematic themes and take a look under their hood's to see what they're doing. Most of what you want has and is being done, its all free, so steal it, emulate it, learn from it.

    It took me months to get anywhere with this theme framework, mostly due to its lack of doc's and small community. The reason I come here and try to work the forums a little is because when I first got into thematic, I didn't feel like waiting 5 days for a reply on the forums, so I figured things out myself. I'm still only half-assed at it, but I can do most of what I want to do, and now that i'm "getting it", i can do it quickly.

    I'm hoping that by trying to give back, more folks will do the same, and maybe some day one of these guys will actually produce more indepth doc's (something I'm working on myself, btw, based on my own experiences with Thematic, but side-projects always take forever...)

    Posted 4 years ago #
  3. paultp
    Member

    Hi,

    I removed the the "Category Archives:" titles on category pages using the following (basic) code:

    //Get rid of the category page titles
    function remove_page_title() {
    if (is_category()) {
    $content ='';
    }
    return $content;
    }
    add_filter('thematic_page_title','remove_page_title');

    There's probably a much smarter way of doing it but this works on category pages.

    Cheers
    Paul

    Posted 4 years ago #
  4. paultp, that code should indeed remove the "category archives" completely.

    erikvlie, try

    function childtheme_override_page_title()  {
    		global $post;
    
    		$content = '';
    		if (is_category()) {
    				$content .= '<h1 class="page-title">';
    				$content .= __('Classification:', '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>';
    		}
    		$content .= "\n";
    		echo apply_filters('thematic_page_title', $content);
    	}
    Posted 4 years ago #
  5. its my understanding, you dont add action when using childtheme_overide
    e.g

    add_action('thematic_page_title','childtheme_override_page_title');

    you also need to ensure you are using a newer revision of thematic for childtheme_overide function to work

    Posted 4 years ago #
  6. Jonny: I'm interested in doing exactly the same thing, myself, but adding your code to my functions.php file makes no changes and placing the add_action at the bottom give a white screen.

    Still looking for a solution to change just the title area for categories without having to duplicate the entire title function from content-extensions.php

    Posted 3 years ago #
  7. Just found this other thread that addresses this question.

    http://forums.themeshaper.com/topic/filter-thematic-loop

    Posted 3 years ago #
  8. have to agree w/ tarpontech, 100%. i think the amount of docu and support is pretty amazing considering it is all free. but i think it is always worth asking yourself... do i really want to learn how to code w/ a framework? or do i just need one-shot theme. if it is the later, the time-investment to learn thematic is not probably worth it. if it is the former, then thematic is super powerful and will let you build all kinds of neato sites. i too, took a long time (4-6 months... which is about the time it takes to learn a foreign language!) to get my head wrapped around thematic and i try to 'give back' as a means of paying forward all the help i have received from others. AND as a bonus, helping others solve their problems has taught me a TON. tho i definitely wish there was at bare minimum a decent search function as it does get old answering the same question repeatedly.

    but to answer the OP's question and hopefully explain a little about the override functions

    this is what the override should have looked like

    function childtheme_override_page_title(){
    
    global $post;
    
    $content = '';
    if (is_category()) {
    				$content .= '<h1 class="page-title">';
    				$content .= __('Classification:', '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>';
    			}
    
    		$content .= "\n";
    		echo apply_filters('childtheme_override_page_title', $content);
    
    /*the apply_filters really baffled me for a long time until i realized i had to change the function name therein.  it should reflect your override function's title.  otherwise you can change the override function, but the filters will always be applying the regular function so you will never see a change and major head-slappage will ensue.
    */
    
    }
    /*no add_action, bc override is called in place of thematic_page_title by IF statement... see content-extensions.php */

    hopefully that clears up overrides, BUT all that being said... if you are only trying to change the title on the category pages i think you'd be better served by a filter. if you go w/ the above override you LOSE all the title information for posts, pages, taxonomies... pretty much everything that isn't a category since you function ONLY defines what to do in case of is_category. otherwise, the $content variable stays null. you could copy the entire function over, but again i think you'd be better served by a filter.

    /*
    if you want to preserve original data (for instance for is_tag and others then you need to pass the $variable you are filtering from the parent function to the child function in the function paramets aka.... in the parens
    */
    
    function childtheme_page_title($content){
    
    if (is_category()) {
    /*note in this case you must get rid of the .= here and replace it with = or else you will get double results. the .= just means that you are adding something on the end of the existing variable and the variable was already defined in the parent function*/
    $content = '<h1 class="page-title">';
    $content .= __('Classification:', '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>';
    }
    
    $content .= "\n";
    
    /*when filter you must always end your function w RETURN $variable or else nothing gets sent back to the parent function */
    
    return $content;
    }
    
    add_filter('thematic_page_title','childtheme_page_title');

    hope that clears some stuff up.

    Posted 3 years ago #
  9. Excellent explanation Helga. Thanks.

    I added the override and filter tags to this thread. I think if we made more use of the tags it might help when trying to find specific topics

    Posted 3 years ago #

  10. Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.