user2502658
user2502658

Reputation: 115

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.

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

Upvotes: 1

Views: 8089

Answers (2)

Muhammad Shahzad
Muhammad Shahzad

Reputation: 9652

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.

Upvotes: 7

Desh
Desh

Reputation: 175

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.

Upvotes: 0

Related Questions