Page title posts page
-
Hi there,
I am using twenty twelve. I have a single posts page (news) on my website. All my other pages have the page title appearing on it apart from my news page.
Any ideas please?
Many thanks,
Kirsty
-
the ‘posts page’ is generated by index.php;
to have the page title appear in the ‘posts page’ you will need to do some coding;
start by creating a child theme of Twenty Twelve to work with;
http://codex.ww.wp.xz.cn/Child_Themes(it is not recommended to edit the default theme directly)
copy index.php into the child theme;
edit index.php;
after this line:<div id="content" role="main">add:
<?php if( is_home() && get_option('page_for_posts') ) : ?> <header class="entry-header"> <h1 class="entry-title"><?php echo apply_filters('the_title',get_page( get_option('page_for_posts') )->post_title); ?></h1> </header> <?php endif; ?>Thank you that works a treat! Next question – could you tell me how to edit the sidebar on the posts page please? I want to add a title to this and display news posts.
Many thanks in advance,
KirstyHi, I figured out how to edit the sidebar.
Please can you tell me how to get a title on the single posts page? Currently the post title is appearing as the page title.(i.e. when you click through into a post).
Many thanks,
KirstyPlease can you tell me how to get a title on the single posts page? Currently the post title is appearing as the page title.
can you post a link to an example post?
this would be handled by single.php and content.php of Twenty Twelve, and it should show the post title;
from content.php:
<?php if ( is_single() ) : ?> <h1 class="entry-title"><?php the_title(); ?></h1> <?php else : ?>Hi
This is my test News page. http://vip.codestring.co.uk/index.php/news/ which does show the tile.
If you click through to the blog there is no page title.
Thanks a lot in advance,
KirstyI don’t know what other title you expect to see on a single post.
are you referring to the meta title?
can you post a link where it does not show a title? and explain what you want to see?
Apologies, this is the first news page I have done so not too familiar with how it should look. I was still hoping to see the News page title. Would this be possible?
Tx,
Kirstyyou can output the ‘news’ title before the single post title;
in content.php, edit this section:
<?php if ( is_single() ) : ?> <h1 class="entry-title"><?php the_title(); ?></h1>for example, change to:
<?php if ( is_single() ) : ?> <?php if( get_option('page_for_posts' ) ) { ?> <h1 class="entry-title news-title"><?php echo apply_filters('the_title',get_page( get_option('page_for_posts') )->post_title); ?></h1> <?php } ?> <h1 class="entry-title"><?php the_title(); ?></h1>(you can use the new
.news-titlecss class for formatting; no idea if this messes with the seo ideas of how to use the h1 tag)OK thanks for your help, in that case I will leave well alone.
Thanks a lot, I appreciate your reply.Kirsty
The topic ‘Page title posts page’ is closed to new replies.