How can I get all text in the h2 tags on my blog post.

SOLVE
New Contributor

I want to get all text in the h2 tags on my blog post body.

Anyone help me

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
Highlighted
Regular Contributor

Hello @nhokloz1059
      Just open the blog post template and you will find the  {{ content.post_body }in the post template's hubl code. just wrap that hubl with h2 tag like <h2>{{ content.post_body }}</h2> and all your post content will be in h2 tag.

Please note that this will wrap all the content having inline images, p tags everything. if you want spacific content than you have to use jQuery solution for it.

Hope this helps.

6 Replies 6
Esteemed Contributor

Hello,

 

You want to get all the h2 text, and do what with it?

 

If you just want to get it, I guess you could use the jquery ".text()" method and create an arry from the data.

Reply
0 Upvotes
New Contributor

I want to create auto category by get h2 tags.

Reply
0 Upvotes
Esteemed Contributor

Ahhh! So this is extremely easy to do with jQuery which you may know.

 

Unfortunately I haven't the knowledge of how to do so with hubl. Or how to pass data between the two. I will continue to research and follow this thread. If you do find a solution please let us all know!

 

Thanks

Reply
0 Upvotes
New Contributor

Yes. Thank you. I am looking forward to your help.

Reply
0 Upvotes
Highlighted
Regular Contributor

Hello @nhokloz1059
      Just open the blog post template and you will find the  {{ content.post_body }in the post template's hubl code. just wrap that hubl with h2 tag like <h2>{{ content.post_body }}</h2> and all your post content will be in h2 tag.

Please note that this will wrap all the content having inline images, p tags everything. if you want spacific content than you have to use jQuery solution for it.

Hope this helps.

New Contributor

Thank you.

I'm done. Using jquery to get h2 tags. And add them into my category. Smiley Very Happy

Reply
0 Upvotes