Im looking to format a piece of text in my content and if its found, to switch it to a link - but when using the example below. the link appears in my text like {a href"…"}Hello{/a} … so its replacing my < > symbols with { }.
Thanks in advance!
Side note - it’s also striping any HTML tags inputted by the WSWYG editor and formats the content into one big block - i guess I’ll have to manually insert the HTML to get these back?
Hey Jack, that’s a really interesting use case! I’d never tried that but you’re right that it seems like using the Get tag with its “normal” syntax (like <Get hello />) works correctly and renders your hyperlinked text, but for some reason when you use the syntax that puts the tag in the value of an attribute (like "{Get hello }") it doesn’t work and replaces the angle brackets with curly braces and outputs the HTML tags as a text string. I tried using a template variable too (<Set template=hello />) and it had the same behaviour. I assume the replace and with attributes are designed for replacing simple text strings, so that with attribute is interpreting <a href=... as a string and not as HTML code. I think this is the expected behaviour since Format replace is currently designed to replace one string with another. That being said, I can see the value in expanding this to allow it to replace a string with some HTML or even an entire template. I’ve added this feature request and I’ll let the devs look into the feasibility of this.
Huh, that’s an interesting idea @Sunskie! I just gave it a try to attempt consolidating that into a single line using replace_2with_2 but it looks like you need to run the formatting twice at a minimum: once to add the HTML tag and once to swap the curly braces with angle brackets. So this would be a (very slightly) more efficient way of achieving that:
Still hacky, so we’ll see what the devs come back with to make it possible to work with tags and templates within Format replace instead of just text strings in a future update. Also just a quick tip: you guys might want to check out this post about formatting your code blocks in Discourse. A bit easier to work with than screenshots
I’m glad the solutions here are working for you! We’ll still have the devs look into the feasibility of allowing Format replace to work with markup/templates so I’ll post back here if we end up releasing that in a future update.
Thanks for the kind words about Loops & Logic! If you’re interested, we’re trying to bump our plugin’s rating up to 5 stars, so if you’re happy with the capabilities of the plugin and the support you’ve received, it’d mean the world for our small team if you’d consider adding that as a review on the WordPress repo. Good luck with your future L&L experiments!