Hide or remove substring in blog article

New Member
13 0 0

I'm trying to figure out how to hide any words that after the character '#' in a blog article using liquid. Is there some creative way to hide it using a combo of css/liquid/html?

 

I want to allow the client to type in some #words with links in the blog but they won't be visible in the body of the article. I'm grabbing the #words + link to make them as specially formatted captions under the photos in the blog article. 

Any help or ideas would be greatly appreciated!

0 Likes
Shopify Expert
2490 417 525

HI @Rachella 

You can split word by # and get text after # like bellow:

{% assign blog_text='My name is #Jasoliya '%}
{% assign blog_text_hash= blog_text | split:'#'%}

Hello, {{blog_text_hash[1]}}

O/P: Hello, Jasoliya
Want to modify or custom changes on store hire me.
If helpful then please Like and Accept Solution.
Email: jasoliyabrijesh123@gmail.com
Skype: jasoliya.brijesh
Want to get Free review and advice for sale on store ?? just text me here
0 Likes
New Member
13 0 0

@Jasoliya wrote:

HI @Rachella 

You can split word by # and get text after # like bellow:

{% assign blog_text='My name is #Jasoliya '%}
{% assign blog_text_hash= blog_text | split:'#'%}

Hello, {{blog_text_hash[1]}}

O/P: Hello, Jasoliya

Thanks for the reply. 

I'm okay to get it .. but how do I remove it? especially if it's more than one word. For example, the client types "#hello world" in the blog article and I want to use liquid/html/css to hide it. 

{%if article.content contains '#' %}
{% assign hashTag = article.content | split '#'%} //hide all words after the # {% endif %}
0 Likes
Shopify Expert
2490 417 525

If you have any perceptible work then you can replace or remove by this:

{{ "Take my protein pills and put my helmet on" | replace: "my", "your" }}
Want to modify or custom changes on store hire me.
If helpful then please Like and Accept Solution.
Email: jasoliyabrijesh123@gmail.com
Skype: jasoliya.brijesh
Want to get Free review and advice for sale on store ?? just text me here
0 Likes
New Member
13 0 0

@Jasoliya wrote:

If you have any perceptible work then you can replace or remove by this:

{{ "Take my protein pills and put my helmet on" | replace: "my", "your" }}

Thanks for the quick reply. I won't know what words they will use. I just know that it will be up to 3 words (#hello or #take it easy). If it's just a single word, then I could get away with remove_first ... but what if it's more? 

0 Likes