Site logo

Archived topic

Two-line post title

6 replies · Started by Daniel on August 19, 2022

Viewing posts 1–7 of 7

If I simply add a snippet: echo str_replace(' | ', '<br />', get_the_title());, assign it to front end, then put a bar in my title where I want the line break, it should work, right?

This is my | Two line Title

Should become:

This is my
Two line Title

It's not working, for some reason.

Based on this post, there is a way to do it using the Headline block (generateblocks, I assume). Here's what I tried:

  1. Create new element, choose "Block"
  2. Element type = Hook? or Site Header? (I tried both)
  3. Create Headline block
  4. Select dynamic option = Title
  5. Select my location (in this case: Blog and Post)
  6. Select the Headline block that's displaying the Title, and in Advanced > Additional CSS Class(es) add: dynamic-post-title
  7. add code snippet suggested by David, activate it on Front end
  8. Empty cache, refresh blog page and single post page that uses "|" as a line-break"

Nothing changed for me. What am I missing?

Thx

Hi there,

If I simply add a snippet: echo str_replace(' | ', '<br />', get_the_title());, assign it to front end, then put a bar in my title where I want the line break, it should work, right?

No, it won't. It's not a function, it won't affect any part of your site.

The steps you listed seem right. Can you link us to your site where this element is activated?

Should step#2 (Element) be set to Hook or Site Header? I currently have it set to Hook. I set up the post with the longest title to appear as a two-liner (notice the bar before the parenthesis).

Ying, by the way, when I mentioned my snippet, I didn't put the php tags in (since the snippet pluggin does that). So, the result would be: <?php echo str_replace(' | ', '<br />', get_the_title()); ?>. Still no good? (See this link).

Can you share the link to your site along with the login details?

Should step#2 (Element) be set to Hook or Site Header?

I don't think site header is what you are after, this option will override the default site header entirely.
You can choose any hook where you want the title to be.

So, the result would be: <?php echo str_replace(' | ', '<br />', get_the_title()); ?>. Still no good?

No...Unfortuanly..

It's just outputting the title, you can put it in a hook element and tick the execute PHP box, select a hook and location, you will see what I mean :)

I want it to appear in the header exactly where the current title resides... I've been setting the Element to Hook and several hook names in the header category, but...nada. :)

Can you share the link to your site? I haven't been able to see your site yet.

Let me know!

This archived topic is closed to new replies.