ThemeShaper Forums » Thematic

[closed]

adding image & hiding page title from the archives

(16 posts)
  • Started 4 years ago by meneldor
  • Latest reply from michaelmior
  • This topic is not resolved
  1. hi!
    I would really like to hide the "category archives: "my_category" "-text from my archives, and throw in an image instead (kinda like a header image).
    I'm not making much sense out of the archives template php files, but I'm a kut'n'paste ninja.
    Made this quick mockup to illustrate:
    Less like this: http://farm5.static.flickr.com/4037/4341775558_7e335cbd65.jpg
    and more like this: http://farm5.static.flickr.com/4039/4341033785_b48861d3ee.jpg

    How would I go about?

    Posted 4 years ago #
  2. Hi,

    this is the code four your child theme's functions.php:

    function my_page_title($content) {
    	if (is_category()) {
    		return 'Enter your code for the image here!';
    	} else {
    		return $content;
    	}
    }
    add_filter('thematic_page_title', 'my_page_title');

    Chris

    Posted 4 years ago #
  3. I whammed in this, but it breaks my site like biscuits. What's faulty?

    function my_page_title($content) {
    if (is_category('music')) {
    return '<img src="img/music.jpg" alt="music"'>;
    } else {
    return $content;
    }
    }
    add_filter('thematic_page_title', 'my_page_title');

    Posted 4 years ago #
  4. Me thinks you have the ending single quote on the wrong side of the ending img bracket.

    Also, I think you should enter the id number of the music category instead of using 'music'

    But how do you just remove the text "Category Archives" but leaving the category title?

    Posted 4 years ago #
  5. okay, so now I have this in my functions, but IE, FF & Safari gives me "image not found" placeholders, even though I'm positive that the image is in the right place on the server. Is my markup right, or what is it?!?


    // CATEGORY ARCHIVES HEADERS
    function my_page_title($content) {
    if (is_category('5')) {
    return '<img src="img/music.jpg" alt="music" />';
    } else {
    return $content;
    }
    }
    add_filter('thematic_page_title', 'my_page_title');

    Posted 4 years ago #
  6. To be on the safe side I would use an absolute URL for the image.

    You could also try using "../img/music.jpg" if Wordpress adds the category-part into the WP URL (for example http://my.site.com/wordpress/category/music instead of http://my.site.com/wordpress/music and you have your image in http://my.site.com/wordpress/img)

    Posted 4 years ago #
  7. Hi,

    please do not use a relative path within your themes / child themes, this won't work.

    Using a relative path will result in something like yourdomain.com/img/picture.jpg for the home page, yourdomain.com/about/img/picture.jpg on your About page and yourdomain.com/category/whatever/img/picture.jpg for a category page.

    The code should be:

    return '<img src="' . STYLESHEETPATH . '/img/music.jpg" alt="music" />';

    Chris

    Posted 4 years ago #
  8. alright, so now I have this, still no go:


    // CATEGORY ARCHIVES HEADERS
    function my_page_title($content) {
    if (is_category('5')) {
    return '<img src="' . STYLESHEETPATH . '/img/music.jpg" alt="music" />';
    } else {
    return $content;
    }
    }
    add_filter('thematic_page_title', 'my_page_title');

    When using firebug, i see that the url for the image is reaaly funky: /home/1/j/jacoblysgaard/www/wp-content/themes/thessia/img/music.jpg
    what's that all about?

    Posted 4 years ago #
  9. I found the issue!
    i have wp-superCache installed. When I deleted the cache, everything works fine like this:
    return '<img src="http://www.jacoblysgaard.com/wp-content/themes/thessia/img/music.jpg" alt="music" />';
    Thanks a bunch to Chris & Gnurf for helping out.

    Posted 4 years ago #
  10. SHIT. When i input several of these, it breaks everything. How should i apply this code to all the different categories then? lookie here:

    // CATEGORY ARCHIVES HEADERS
    // music
    function my_page_title($content) {
    if (is_category('5')) {
    return '<img src="http://www.jacoblysgaard.com/wp-content/themes/thessia/img/music.jpg" alt="music" />';
    } else {
    return $content;
    }
    }
    add_filter('thematic_page_title', 'my_page_title');
    // art/design
    function my_page_title($content) {
    if (is_category('3')) {
    return '<img src="http://www.jacoblysgaard.com/wp-content/themes/thessia/img/art-design.jpg" alt="art and design" />';
    } else {
    return $content;
    }
    }
    add_filter('thematic_page_title', 'my_page_title');
    // inspiration / general nonsense
    function my_page_title($content) {
    if (is_category('4')) {
    return '<img src="http://www.jacoblysgaard.com/wp-content/themes/thessia/img/inspiration.jpg" alt="inspiration" />';
    } else {
    return $content;
    }
    }
    add_filter('thematic_page_title', 'my_page_title');

    Posted 4 years ago #
  11. @meneldor: I'm sure you can combine it into one if, elseif? From what I've understood, the same function being filtered again and again, so only the last one will display, as it effectively cancels out the last one.

    Oh by the way, you can put code in-between backquotes.

    // CATEGORY ARCHIVES HEADERS
    // music
    function my_page_title($content) {
    if (is_category('5')) {
    return '<img src="http://www.jacoblysgaard.com/wp-content/themes/thessia/img/music.jpg" alt="music" />';
    } elseif (is_category('3')) {
    return '<img src="http://www.jacoblysgaard.com/wp-content/themes/thessia/img/art-design.jpg" alt="art and design" />';
    } else{
    return $content;
    }
    }
    add_filter('thematic_page_title', 'my_page_title');
    ?>
    Posted 4 years ago #
  12. nope. That code breaks everything, just like the one I posted above. Thanks anyway =)
    Anyone else? I'm dying here!

    Posted 4 years ago #
  13. @meneldor: Unfortunately I accidentally left in ?> at the end so could you try the same thing again without the extra ?> at the end please?

    Posted 4 years ago #
  14. You can't declare a function more than once.

    Put everything into one function and cascade that if (is_Category()) stuff, or give each function a unique name.

    Chris

    Posted 4 years ago #
  15. Works!
    Thanks everyone! Owe you bigtime!

    Posted 4 years ago #
  16. michaelmior
    Member

    This solution doesn't work for me. I tried this to remove all page titles:

    function my_page_title($content) {
    	return''
    }
    add_filter('thematic_page_title', 'my_page_title');

    Doesn't work :( Suggestions anyone?

    Posted 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.