• Thanks to you fine people on Codex, I found out how to take the post title of my static pages that I’m using for my website.

    However, I want post titles for my blog which is one of the pages but not static.

    How do I get the titles on the posts but not on the static pages? What PHP file should I modify? What code does that?

    I read that I can have titles on any posts if they are categorized blog posts. But, what PHP file is that?

    Thanks.

Viewing 15 replies - 16 through 30 (of 37 total)
  • Omitting titles on certain pages like the homepage can be problematic from a search engine standpoint if you are simply removing it in the post_title.php file. This is because the title tag is an important component of that SEO equation.

    I would recommend that to hide titles on specific pages/posts using the Post ID and a bit of CSS to make it dissappear. For example if you had a post ID of “5” for your homepage you could include a simple line of code in your style sheet such as:

    .post-5 h1 {display:none !important;}

    Doing this will essentially make that header with the assigned style h1 invisible on only the page with the post ID of “5”. The only variable here would be the post ID number. So if you had a post ID of “15” that would be the ID you would want to include in the new CSS Style. The reason I included !important in the string is so that the new CSS code is forced to override any other code in your stylesheet.

    Just a note: I have used this with great success on several premium themes and theme frameworks but have not specifically tried this method with the TwentyTen theme.

    LJagermaster

    (@the-living-legend)

    Just curious, wouldn’t that also hide the title from the post itself? I’m unsure as to how that will effect post lists such as archives etc… :-/

    SEO isn’t a real issue for us as we’re using the Platinum SEO plugin (successor to the All In One SEO plugin) so we’ve got all that taken care of.

    Thanks tho Rob for your reply, much appreciated. I guess I’m just a born skeptic! X-D

    Yes, it will. Maybe I misunderstood the intent of this topic. The post title may have thrown me. I was under the impression that we were looking for a way to strip the title visually from a static page but not from posts. The method I discussed above will do just that. However, it will remain in the source code for the page which is good for SEO so long as it is titled something relevant to the pages content. Sorry if I mislead you. Hopefully the information is useful to someone out there.

    Thanks for posting your solution – it’s exactly what I’m looking for. I tried pasting the code you provided into my functions.php file and it crashed my site. I’m still testing on my local machine, so it’s OK. I tried it on another test site with a different theme, and this time it didn’t crash, but the php just appeared “above” the page.
    Is there somewhere specific it’s supposed to be pasted?
    I’d really like to get this working, as I can’t expect my client to add to the css every time they create a new page.
    Thanks!

    Not sure if the comment above was directed at me. There are many methods to “delete a post title from a static page” that are discussed here. The method I mentioned above assumes you are trying to visually hide the title on a single static page rather than the entire site. The code I provided was was intended for use in your style sheet only! Changes to the CSS file impact the front end look and feel but do not alter any back end functionality. Therefore, they can easily be reversed by removing the style. Changes to the functions.php file can indeed wreak havoc if not done properly. If you are trying to hide the title globally you may be able to achieve this by altering the code in your single.php file but the CSS method described above is not how this is generally handled and the solution may vary depending on how your theme was coded.

    Thanks for your response Rob. I’ve looked everywhere for a css solution to removing page titles globally but not post titles. It seems that it’s fairly easy to remove both. In my theme (a modified twentyten) there seems to be no distinction between posts and pages.
    Can you suggest any leads to follow?
    Thanks!

    Give this a try. You said you were working off of a modified twenty ten theme. Go into your page.php and replace everything that is in there with the following code.

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Sorry forgot to end my code tag:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    That should keep titles on your blog post pages but remove them from all the static pages. Not sure what this will do as far as SEO goes by completely removing the title tag but nonetheless it is a method worth trying.

    Hi Rob
    Thanks for this. I’m not sure I want to remove everything else – there’s a lot more in there, and I’m nervous to replace it. It’s actually a twentyten theme modified to inherit Joomla styles as I’m using WP as a component. Is there no css-only solution, or something like a custom field method that can be added on the front end by a user without going into the php?
    I appreciate your time!

    Take a look at the original Twenty Ten page.php file and you will be able to figure out what has been added to your theme and what was original. There is not much in the original so I am assuming that your theme has been customized quite a bit.

    As far as I can tell there is no easy way to target the headers/titles for post and pages separately on a global basis using a CSS only solution. You can only do it for individual post IDs but as you mentioned earlier that really isn’t a feasible option for what you are trying to achieve. Wish I had a better answer for you.

    I’ve read all these messages and still don’t know how to remove the page titles from pages (but leave blog post titles) with the twenty ten theme. FYI, my page.php file contains very little code.

    Paste your page.php code in https://wordpress.pastebin.com and paste url here so we can see the code.

    Oops, did that wrong. Will fix…

Viewing 15 replies - 16 through 30 (of 37 total)
  • The topic ‘Delete post title from static page but not blog’ is closed to new replies.