ThemeShaper Forums » Thematic

[closed]

Removing Page Titles, Not Hiding Them...How?

(21 posts)
  • Started 10 years ago by awarner20
  • Latest reply from paaljoachim
  • This topic is resolved
  1. Is there a filter to completely remove page titles? I know I can hide them using css `body.page h1.entry-title {
    display: none;
    }`

    ...but this is leaving a bunch of white space. I also have a need to remove page titles on only some pages and not others.

    Anyone doing this with a filter?

    Posted 10 years ago #
  2. amygail
    Member

    There may be an answer here

    http://themeshaper.com/filters-wordpress-child-themes/

    Posted 10 years ago #
  3. Hi amygail,

    I've managed to create a function to apply a filter to post meta. However, I must be dense because I am not seeing a filter for page titles?

    //REMOVE POST META FROM POSTS
    function remove_postmeta() {
    	echo '';
    }
    add_filter('thematic_postheader_postmeta','remove_postmeta');

    I tried the WordPress wp_title filter, but it didn't work. Can someone point me in the right direction?

    Posted 10 years ago #
  4. amygail
    Member

    I'm guessing it's

    thematic_postheader_posttitle

    (look in your content-extentions.php)

    Sorry I'm not more help

    Posted 10 years ago #
  5. Hi amygail...not post titles, PAGE titles...

    Posted 10 years ago #
  6. I thought I found it (thanks for pointing out content extensions), thematic_page_title...

    ...but my function isn't working...

    //REMOVE PAGE TITLES
    function change_page_title() {
    	echo '';
    }
    add_filter('thematic_page_title','change_page_title');
    Posted 10 years ago #
  7. It is working, but only on these pages...

    // Filter the page title
    // located in archive.php, attachement.php, author.php, category.php, search.php, tag.php

    I'm trying to remove the page title on a single page. I'm now searching for a single page title filter. Why aren't all these filters listed here? http://themeshaper.com/thematic/guide/?page_id=12

    Posted 10 years ago #
  8. amygail
    Member

    I'm assuming there's been a lot of dev on the theme since that was written.
    Reading through the extensions files can be pretty enlightening.
    Unfortunately at my skill level, they're filled with more clues and questions than answers...

    I'm GUESSING you'll need to use conditional statements or something

    There must be a clue in this series...
    http://themeshaper.com/modify-wordpress-themes/

    Chris will be back soon!

    Posted 10 years ago #
  9. @awarner20 did you find a solution for this?

    I tried exactly the same thing : add_filter('thematic_page_title', 'childtheme_page_title');

    ... but to no avail :(

    Posted 10 years ago #
  10. The hook is poorly named, this is the one I wanted :

    add_filter('thematic_postheader_posttitle','childtheme_page_title');

    Posted 10 years ago #
  11. I think the filter you all are looking for is thematic_postheader_posttitle . You can look in content-extentions.php to see what's going on in there. Basically there is a conditional statement if single || page elseif 404 else the default. It tags the page title or single post page title with an h1 or 404 page title with an h1 or it defaults to an h2.

    I also think it would be really helpful if these hooks were better documented either in the wiki if not also in the templates in the form of a comment block after a thematic function with a list of available filters.
    i.e.
    <?php thematic_postheader(); // available filters: thematic_postheader , thematic_postheader_posteditlink , thematic_postheader_posttitle, thematic_postheader_postmeta ?>

    Posted 10 years ago #
  12. As far as the whitespace is concerned in default.css the #main div has padding-top:66px and the .entry-content div has padding-top: 22px. I think those declarations are what you want to adjust in your childtheme's style.css to get your desired effect.

    Regarding removing the page/post titles entirely, I think that it does more harm to SEO than good for design especially since I believe the undesired 'whitespace' can be dealt with via css. It's just a little tricky to see how the other elements work to create padding around the titles in the default design.
    I wasnt sure what you meant by 'Pages' so here is how you'd go about removing the page titles entirely on WordPress Pages.

    function child_remove_pagetitles() {
       // Make changes to the original function
       if (is_page()) {
              $posttitle = '';
           } elseif (is_single()) {
              $posttitle = '<h1 class="entry-title">' . get_the_title() . "</h1>\n";
       //continue with original function
           } elseif (is_404()) {
               $posttitle = '<h1 class="entry-title">' . __('Not Found', 'thematic') . "</h1>\n";
           } else {
               $posttitle = '<h2 class="entry-title"><a href="';
               $posttitle .= get_permalink();
               $posttitle .= '" title="';
               $posttitle .= __('Permalink to ', 'thematic') . the_title_attribute('echo=0');
               $posttitle .= '" rel="bookmark">';
               $posttitle .= get_the_title();
               $posttitle .= "</a></h2>\n";
           }
       return $posttitle;
       }
    add_filter('thematic_postheader_posttitle' ,'child_remove_pagetitles')

    You can change the conditional to suit your needs adding or removing markup for titles on templates other than the page template.

    Posted 10 years ago #
  13. Thank you so much. Exactly what I needed.

    Works excellent to remove the permalink <a> Element from the post titles!

    Posted 9 years ago #
  14. @em hr

    Just wanted to say thanks for that little php script to remove the page titles. I wanted to remove it only for my Home page, so I modified it with this bit of logic (in case anyone else searches here for the same thing):

    //Remove Home page title
    function child_remove_pagetitles() {
       // Make changes to the original function
       if (is_home() || is_front_page()) {
              $posttitle = '';
           } elseif (is_single()) {
              $posttitle = '<h1 class="entry-title">' . get_the_title() . "</h1>\n";
       //continue with original function
           } elseif (is_404()) {
               $posttitle = '<h1 class="entry-title">' . __('Not Found', 'thematic') . "</h1>\n";
           } else {
               $posttitle = '<h2 class="entry-title"><a href="';
               $posttitle .= get_permalink();
               $posttitle .= '" title="';
               $posttitle .= __('Permalink to ', 'thematic') . the_title_attribute('echo=0');
               $posttitle .= '" rel="bookmark">';
               $posttitle .= get_the_title();
               $posttitle .= "</h2>\n";
           }
       return $posttitle;
       }
    add_filter('thematic_postheader_posttitle' ,'child_remove_pagetitles')
    Posted 9 years ago #
  15. initialsbr
    Member

    I would also like to remove the page titles. But I added the code above to my functions.php file after some other functions I've put in there and now all I get is a white screen. There are no spaces below the code, so that's not the problem.

    What am I doing wrong? And what, if anything, am I supposed to modify in the code above?

    Posted 9 years ago #
  16. i had issues with the above too. Here is what I modified it to instead, to get rid of the title on the front page.

    // Create post titles
    function my_posttitles() {
       // Make changes to the original function - remove Post title on Front Page
    	if (is_front_page()) {
    		$posttitle = '';
    
    	//continue with original function
    	} elseif (is_single() || is_page()) {
            $posttitle = '<h1 class="entry-title">' . get_the_title() . "</h1>\n";
        } elseif (is_404()) {
            $posttitle = '<h1 class="entry-title">' . __('Not Found', 'thematic') . "</h1>\n";
        } else {
            $posttitle = '<h2 class="entry-title"><a href="';
            $posttitle .= get_permalink();
            $posttitle .= '" title="';
            $posttitle .= __('Permalink to ', 'thematic') . the_title_attribute('echo=0');
            $posttitle .= '" rel="bookmark">';
            $posttitle .= get_the_title();
            $posttitle .= "</a></h2>\n";
        }
       return $posttitle;
       }
    add_filter('thematic_postheader_posttitle' ,'my_posttitles');
    // end thematic_postheader_posttitle
    Posted 9 years ago #
  17. I used the following code to replace the post title with text from a custom field. Perhaps it'll be useful to someone else:

    /* Custom Post Titles from Custom Fields */
    
    function childtheme_posttitles() {
    	global $post;
    	$custom_title = get_post_meta($post->ID, 'mycustomfield_alttitle', true);
    	if (empty($custom_title)) { $custom_title = get_the_title(); }
    	if (is_single() || is_page()) {
            $posttitle = '<h1 class="entry-title">' . $custom_title . "</h1>\n";
        } elseif (is_404()) {
            $posttitle = '<h1 class="entry-title">' . __('Not Found', 'thematic') . "</h1>\n";
        } else {
            $posttitle = '<h2 class="entry-title"><a href="';
            $posttitle .= get_permalink();
            $posttitle .= '" title="';
            $posttitle .= __('Permalink to ', 'thematic') . the_title_attribute('echo=0');
            $posttitle .= '" rel="bookmark">';
            $posttitle .= $custom_title;
            $posttitle .= "</a></h2>\n";
        }
       return $posttitle;
       }
    add_filter('thematic_postheader_posttitle' ,'childtheme_posttitles');
    Posted 9 years ago #
  18. Hi - this is all good stuff. I tried using helgatheviking's code above which works really well.

    The one question I have is that I notice that on single pages the structure of the page goes <h1> to <h3> and misses out the <h2>.

    Not sure what can be done about this - I like my headings in the right order and nested properly.

    I doubt this is going to be a major problem for SEO though.

    Posted 9 years ago #
  19. I know this is an old thread, but might as well post my solution here.

    function remove_front_pagetitle($posttitle) {
    	if ( is_front_page() ) {
    		$posttitle = '';
    	}
    	return $posttitle;
    }
    add_filter('thematic_postheader_posttitle', 'remove_front_pagetitle');
    
    Posted 8 years ago #
  20. bravo martin. my solution really is overkill, but i barely knew what i was doing a year ago.

    Posted 8 years ago #
  21. paaljoachim
    Member

    Thanks EM for the code to remove the page titles!
    I have not used Thematic since last summer but I am using it for a blog on a film club site. So instead of selecting another theme I decided to for now go with the child theme I had built and expand it. Removing or hiding page titles was one of the things I had not earlier done. I am now building additional pages slowly moving the film club site over from regular html to Wordpress.

    http://spirituellfilm.no/wordpress/blogg

    youtube.com/user/paaljoachim

    Posted 7 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.