• Piero

    (@pierosparviero)


    In order to chop the texts of my blog into small posts, for each subject I wrote several small posts that refer to different aspects of that subject.
    For instance,
    – “Berlin at the beginning of the 19th cent. – Overview”
    – “Berlin at the beginning of the 19th cent. – The neighborhoods”
    – “Berlin at the beginning of the 19th cent. – Social divides “

    How can I control how such titles are displayed?
    May I structure a title on two or more lines?

    I tried to find an answer to those questions, but I didn’t find it. Maybe I didn’t figure out the right words to ask the right questions.

    I found something like “The title block”, which explains that a post’s or a page’s title is part of a query loop, but didn’t really understand the chapter on query loops. Should i learn what is a query loop?

    Thank you for you attention and your help.

Viewing 1 replies (of 1 total)
  • Moderator threadi

    (@threadi)

    How the titles are displayed depends primarily on the theme. Normally, these display the titles as h1 headings so that they can also be read by search engines. Often, the only thing you can control about the headings is the appearance of the text (font size, color, style, decoration, weight, etc.). The use of line breaks or auxiliary HTML elements is generally not intended (and cannot be used when entering text in the block editor). At the same time, however, this title is also used as the page title that is displayed in search engines—it should therefore be free of formatting such as line breaks or auxiliary HTML elements, or these should be removed when using it as a page title.

    In your case, you now need to see how the relevant pages should be listed in search engines. I assume you would want the whole topic to be searchable as “Berlin at the beginning of the 19th century” without the sections ‘Overview’ etc.? Then you would have to output “Berlin at the beginning of the 19th century” as one page and the sections as h2 headings within it.

    Alternatively, you can of course leave the headings as you have written them. A two-column layout as described above is not planned and would only be feasible with additional individual programming:

    add_filter( 'the_title', function( $title ) {
    return str_replace( '[br]', '<br>', $title );
    });

    This allows you to use the placeholder [br] in the title in the block editor to force a line break. This looks nice in the frontend, but the page title on Google still contains this placeholder (which is ugly). This can be solved with the following:

    add_filter( 'document_title', function( $title ) {
    return str_replace( '[br]', ' ', $title );
    });

    You would need to store both codes via the Code Snippet plugin or in the functions.php of your child theme.

    And yes, this is complicated and not an option in WordPress, as it is a rather unusual form of labeling that, as described above, can lead to problems in search engines.

Viewing 1 replies (of 1 total)

The topic ‘Do post titles have two lines?’ is closed to new replies.