ThemeShaper Forums » Thematic


Add h1 title to Blog page

(10 posts)
  • Started 12 years ago by mogito2000
  • Latest reply from wlanni
  • This topic is not resolved
  1. mogito2000

    Hi there,

    Im struggling to get Blog page title to show. I have set the title for the page in Admin but it doesnt seem to be coming through. All other pages seem to show the title of the page.

    Is this default?

    What should i be doing in functions.php to get the title of the Blog page coming through?

    Thank you for any help provided.


    Posted 12 years ago #
  2. wlanni

    Mogito, I'm working on this right now. When I figure it out I'll post back here...

    Posted 11 years ago #
  3. wlanni

    OK, here's what I added to my functions.php to get the category to show up on category pages. I think I misunderstood what you asked... actually, I have no idea what you're asking.

    Blog page title? On what page? The home page where all blog categories etc are featured? On just a category page? On an archive page? When you click on a post and are reading just that post?

    this is too vague, but if you're looking to just put the category title on to a category page, here's what I did:

    //put a blogtitle into category archive page
    function blogtitle_on_category_page() { ?>
    		<h1 class="entry-title"><?php single_cat_title(); ?></h1>
    <?php }

    Unfortunately, it doesn't put the title on the single post page. I'm still trying to figure that one out.

    Posted 11 years ago #
  4. wlanni

    //put blogtitle onto a single page
    function blogtitle_on_single_page() {
    	if (!is_date()) {
    	<h1><?php $categories = get_the_category(); foreach($categories as $category) { $cat_name = $category->name; if($cat_name != 'featured') echo '<a href="'.get_category_link($category->term_id).'">'.$cat_name . '</a> '; } ?></h1>
    <?php }
    Posted 11 years ago #
  5. I have a similar issue: Home page is a static page, blog posts are set to display on a page titled "News"... How to get the title to show on that News page? (not just any category archive) Thank you, if you can help...

    Posted 11 years ago #
  6. jackvalet

    Posted 10 years ago #
  7. wlanni

    Lizm, I'm sorry I never came back and looked at this. I dealt with this issue as well. It's been 7 months, but... maybe this will help someone else.

    When you set your home page to a static page, and then set the blog page to a different page, it's still referencing the home or "index" page as that blog page. Ok, keep that in the back of your head, we'll come back to that.

    This took me a LOT of diddling about, and between the following two functions, I finally worked out what the different page titles and such are.

    In your child theme, you're going to want to use the childtheme_override_page_title and childtheme_override_postheader_posttitle. I'll give examples below. As a reference, you can find the original functions to copy and paste from in thematic/library/extensions/content-extensions.php. Page Titles are at line 179 and below, postheader is at line 618.

    OK, first off, what the heck is the difference?!

    A Posttitle is the title of a post. If you're viewing a SINGLE BLOG POST, or a PAGE, (not your blog index page) and you want to alter the title, you'll be editing using the postheader_posttitle override. Otherwise, the posttitle will be the titles of each post in a list of posts (like on an archive), and the Page Title will control the title of the page, as my next paragraph describes.

    On the other hand, the page title appears on category pages, your archives, attachment, search, tag pages, etc. This is the page title above a list of posts. For this, you'll need the page_title override.

    OK, so how do you make use of this?

    In your CHILD THEME FUNCTIONS (you are using a child theme right?), simply insert the following to replace (or "filter") the default content-extensions.php functions. (this way, you don't have to alter the original code).

    In my following example, I created my own personal custom post type called pstf_events, AND I had a blog with its own single blog pages. I needed to throw a little rss icon in the regular blog page post titles, and not have the pstf_events be affected. Hence, the first conditional says, "is_single()" -- is this a single blog post -- and the post type doesn't equal pstf_events. If you compare the following function to the content-extensions postheader_posttitle, you'll see how I start manipulating post titles in specific places:

    // Create post title
    function childtheme_override_postheader_posttitle() {
    	if (is_single() && (get_post_type() !='pstf_events')) {
    		$posttitle ='<h1 class="page-title single"><a href="/festival-alerts">&laquo; <img src="';
    		$posttitle .= get_bloginfo('stylesheet_directory') . '/images/btn-rss-small.png"';
    		$posttitle .= ' alt="Back to Festival Alerts" width="23" height="24" />Back to Festival Alerts</a></h1>';
    		$posttitle .= "\n";
    		$posttitle .= '<h1 class="entry-title">' . get_the_title() . "</h1>\n";
    	} else if (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 if (!is_archive() && get_post_type() =='pstf_events') {
    		$posttitle = '';
    	} else {
    	    $posttitle = '<h2 class="entry-title"><a href="';
    	    $posttitle .= apply_filters('the_permalink', 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 apply_filters('thematic_postheader_posttitle',$posttitle); 
    } // end postheader_posttitle

    The next one is massive. Here's where I filtered the Page Titles. You'll see that this function applies to every possible page title in the WordPress system. I had to add an extra for my custom pstf_events. I also had to add a conditional for the home blog page, as that's not included here, which is what you were trying to resolve. By default the thematic index page doesn't have a page title on it. I copied the index.php into my child theme directory, and then on line 18 I added the following couple lines of code:

    // displays the page title

    I similarly did this on my custom post type theme file (made a copy of single.php and renamed it single-pstf_events.php. Thematic will automatically then use that for my single custom post type events.)

    You'll see that under the is_home(); in this case I needed a really big rss button sitting inside the page title, and I needed the page title to link to the rss feed.

    A couple lines below, I have a couple of conditionals that customize the custom pstf_events post type, as I needed to let my users know that the events were listed in alphabetical order.

    // Filter the page title
    // located in archive.php, attachement.php, author.php, category.php, search.php, tag.php
    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>';
    	} else if ( is_home() ) {
    			$content .='<h1 class="entry-title"><a href="';
    			$content .= get_bloginfo('rss2_url');
    			$content .= '"><img src="';
    			$content .= get_bloginfo('stylesheet_directory') . '/images/icon-rss.png"';
    			$content .= ' alt="Subscribe to Festival Alerts" width="40" height="41" />Festival Alerts</a></h1>';
    	} else if (!is_archive() && get_post_type() =='pstf_events') {
    			$content .= '<h1 class="entry-title">' . get_the_title() . "</h1>\n";
    	} else if (is_archive() && get_post_type() == 'pstf_events') {
    			$content .= '<h1 class="entry-title">' . post_type_archive_title('',false) . " <span style='font-size:smaller'>(Alphabetically)</span></h1>\n";
    	} 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);

    OK, I hope that helps!

    Posted 10 years ago #
  8. Logan

    I want to add a page(page uses its own template) to a view that is called by another page.

    this works and i get the data however i get 3copies of blog.php showing up on index.php I dont understand why this doing this.


    class page_index extends Page {
    function init(){


    home.html (called by index.php):


    class page_blog extends Page {
    function init(){

    //Get Articles

    $page->add('H1')->set('Latest News');

    foreach($articles as $article){


    Posted 10 years ago #
  9. @logan - i have no idea what you mean, nor what your code is doing as OOP is a bit complicated for me still. also, don't forget to put your code between backtick marks, makes it easier to read.

    if you need to pull the content of one post into another why not use get_post() or if a page... then get_page()

    Posted 10 years ago #
  10. wlanni

    I don't understand the question either.

    You want to add a page that uses its own template to a "view" that is called by another page.

    That's got me stumped. I don't know what that means at all.

    Posted 10 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.