I'm currently building a WordPress theme where my page consists of widgets. One widget is a part of the page. I'd like to be able to use anchor links with them, and to do this, I would like to output the widget's title as an ID of the widget.
I know the widget has and ID already but it results in ugly anchor links - the anchor link would be
url.com/#text-2. I would like it to be
In the source code, this is the default HTML output:
<div id="text-2" class="widget-container widget_text">
This is the HTML output I aim for:
<div id="text-2 about" class="widget-container widget_text">
How do I achieve this?
Thanks in advance!
It seems an HTML element can't have two ID's.
Is it possible to instead add an
<a> element within the widget's
widget-title where the ID of the
<a> is the widget's title?
So the HTML output looks like this:
<h2 class="widget-title"><a id="about">About</a></h2>