Forums

[resolved] [Twenty Ten] Sub-headings in posts (5 posts)

  1. ringolingo
    Member
    Posted 10 months ago #

    I want to use sub-headings in posts. I think it would be better to use something like h2 or h3, but Twenty Ten uses h1 for the post titles when showing single posts, and h2 post titles when showing the home page, and also the h3 tag is being used by the comment section.

    I want to use a correct heading structure, i.e, h1, h2, h3, h4; but I don't know how. I want to be able to do it without editing the theme's files and instead use the child theme.

    So far, following the advice of the Codex I've been using h4, but this is far from satisfactory.

  2. peredur
    Member
    Posted 10 months ago #

    If you want to change the HTML tags that are used, you'll have to change the relevant PHP files. Just copy the files you want to change into your child theme directory and make the edits you want.

    I'm not sure I'd get all religious over the h1 - h6 tags, though. You could make a case for them as they are. It just depends on how you interpret the semantics under the different circumstances (home page, single page, single post, list of posts etc). If it were me--- and I know it's not---I'd just alter the CSS for the headings so they looked how I wanted them to look, without actually changing the tags.

    But that's just me...

    Cheers

    PAE

  3. ringolingo
    Member
    Posted 10 months ago #

    My purpose is to have SEO optimized headings, and I know that SEO can be a religion for some people!, as is the need to have some easy to maintain code. I'm looking for maybe a function in functions.php that would search and replace the heading h3 tags in the comments.php and style.css files for h4. I could settle for h3 in my posts sub-headings, even when in the single posts there could be place for h2 sub-headings. That would be a nice solution, but PHP is not my strength.

    I'd just alter the CSS for the headings so they looked how I wanted them to look, without actually changing the tags.

    That's what I did in the end, but I'm still hoping for a better solution.

    Thank you, anyways.

  4. peredur
    Member
    Posted 10 months ago #

    Messing about with your headings in this way won't make a shred of difference to your SEO performance, believe me. Not even a noticeable fraction of one percent.

    However, if you want to change the headings, using a search and replace function is definitely not the way to do it.

    You need to do the following:

    • Ascertain all the situations in which the headings are not to your liking, such as: front page, home page, page, single post, category list, tag list, archive list and so on
    • Once you have that list, you will need to work out using the WordPress Template Hierarchy, the names of the files your theme is using to display pages under these circumstances
    • Hopefully, you are using a child theme. If you are, you need to copy all these files into your child theme folder and alter the Hn tags to suit you. If you're not using a child theme (and you're not happy to start doing so) you'll need to edit the files in situ

    Everything should now be as you want it, although you may have to mess with your CSS to get the headings to display as you want them, depending on what's already in your CSS.

    I should add the disclaimer that this, of course, represents my opinions about these things. Others may disagree, and I'm always open to being shown that I'm mistaken. It's the only way to learn that I know of.

    HTH

    PAE

  5. ringolingo
    Member
    Posted 9 months ago #

    I decided to use an h2 tag for my post sub-headings, instead of an h4, as suggested by the Codex. It makes more sense. The comment titles are already h3, and SEO optimization does make more sense in individual posts. (I guess the Codex was talking about the old Kubrick theme. By the way, the Codex is outdated in many parts.)

    So in the front page there are two kind of h2 tags: the post title tags and the post sub-heading tags, but the in the single posts the heading structure is perfect: h1 for post title, h2 for sub-headings and h3 for comments. There is no conflict with the CSS styles in the front page, because the post titles are handled by the entry-title class.

    So that is my solution, without messing with code in an ugly way. I had only a few posts in my blog, so changing the heading tags was no big deal.

    Now, if I wanted to have a neat heading structure in the front page, THAT would be difficult. You can't always have what you want.

    Thank you.

Reply

You must log in to post.

About this Topic