- This topic has 6 replies, 2 voices, and was last updated 7 months, 1 week ago by Ying.
August 19, 2022 at 12:13 pm #2317824Daniel
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
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:
- Create new element, choose “Block”
- Element type = Hook? or Site Header? (I tried both)
- Create Headline block
- Select dynamic option = Title
- Select my location (in this case: Blog and Post)
- Select the Headline block that’s displaying the Title, and in Advanced > Additional CSS Class(es) add: dynamic-post-title
- add code snippet suggested by David, activate it on Front end
- Empty cache, refresh blog page and single post page that uses “|” as a line-break”
Nothing changed for me. What am I missing?
ThxAugust 19, 2022 at 2:10 pm #2317896YingStaffCustomer Support
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?August 19, 2022 at 3:44 pm #2317956Daniel
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).August 19, 2022 at 3:56 pm #2317961Daniel
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).August 19, 2022 at 4:13 pm #2317968YingStaffCustomer Support
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?
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 🙂August 19, 2022 at 4:49 pm #2317991Daniel
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. 🙂August 20, 2022 at 10:36 am #2318524YingStaffCustomer Support
Can you share the link to your site? I haven’t been able to see your site yet.
Let me know!
- You must be logged in to reply to this topic.