I am working on a WordPress site where multiple posts are to be displayed in a single page. The title of each post is displayed with h2 tags. Now I want to be able to give each of these an id (html id attribute), preferably of my choice so I can link to them (use as anchor).
Link to my page is
https://www.risingidiots.com/photoshop-opening/
2
Answers
That's how I did it :)
First of all in my case what I had to modify was a plug-in- file not a theme file.
What I have done here is to use the title itself as an ID
If you wanted to add id in h2 tag you need to change the code in page-blog.php file.
there is two way to add the id.
if you wanted to add different id for each post as you want then you can just add custom field in each and every post.
then edit file and add the custom field value in h2 tag as ID.
as below.
another way is you just use post id as id for h2 tag.