Add line break in WordPress Post Title

I have long post titles in my wordpress website.

what I would like to do, is insert a line break so that the post title take up 2 lines.

Read More

I have been able to achieve this by using < b r > (no spaces) within my post title.

The problem is now, that wordpress is duplicating my post title “background” image for the second line. So now there are two “rectangles” underneath each other – each with a line of text.

How could I prevent the post title image from duplicating, and keep both lines of text within the one rectangular post title image?

Thank you

Related posts

Leave a Reply

2 comments

  1. Add a comma in title and you could try to replace:

     `<?php the_title(); ?>`
    

    with:

     `<?php echo str_replace(',','<br />',get_the_title()); ?>`
    

    this replaces a comma , in the title with a html linebreak.

    it’s a logic try on yourself.

  2. keep your code which prints title in a single div.apply background image to this div only. then inside this div use as many < br >, the image should not breakup.