I have a static homepage.
I’ve edited the php for the h1 and h2 tags on my template. So that
says The Music Mag – Unsigned Bands
and so on for the other sites. This is edited in the index.php.
BUT my main blog page – where everything goes – doesn’t recognise this for some reason. The code I’m using is bloginfo for the homepage title then wp_title for the pages title. However on the blog page it brings up “page not found”
I’m not sure that
wp_titleisn’t going to work on your home page in this context.Have you tried using
<?php the_title(); ?>?
I’ve tried that esmi,
But then the h1 brings up the title of the last post if i use the_title…i guess it’s better than page not found, but still not ideal. I just want it to say what the page is called, like the other ones do 🙁
I’ve updated it with the_title and you can see what I mean 🙂
You need to edit index.php – not page.php.
<?php if ( is_home() ) : $pp_id = get_option('page_for_posts'); $posts_page = get_page($pp_id); ?> <h1 class="slogan2"><a href="<?php bloginfo('url');echo '/'.$posts_page->post_name;?>"><?php bloginfo('name'); wp_title(':',true,''); ?></a></h1> <?php endif;?>
that doesn’t work.
It brings up my blog page as page not found and all the other pages have no h1 – it dissapears.
Best i’ve got it is using php the_title, but then that makes the homepage have the latest blog title as the h1
thank you for the help though. I tried playing about with it.
Currently this is my h1 code on index.php
<h1 class=”slogan2″>” rel=”bookmark” title=”<?php wp_title(); ?>”> <?php bloginfo(‘name’); ?> » <?php the_title(); ?></h1>
and i think as you suggested, it needs an if function to make it so that when it’s on the blog page it doesnt show the_title, but it shows “blog”
yeah i did esmi. It didn’t work. It made errors on my site and just displayed no h1 at all.
Can I suggest you try again and make sure you add the code exactly as listed above and make sure you do not add it inside any
<?php ?>tags? I’ve just tried that block on one of my sites and it worked fine with no errors.
i think there’s some problem with the template to be honest. I knew there were issues and edited some php in it – wanted to use it as loved the look – but managed to make it workable. So i think it may be some coding stuck somewhere, or some that’s missing from somewhere. Maybe a stylesheet somewhere, i dont really know but
it doesnt work.
I’ve added that in the right place etc.
blog section has “page not found”
and the other pages now have no h1 at all – it dissapears.
- The topic ‘PHP for wp_title brining an error on index.php’ is closed to new replies.