L
L
Laid2016-04-09 17:37:11
PHP
Laid, 2016-04-09 17:37:11

WordPress | How to uniqueize widget selectors?

Good evening.
There are wrappers

<div id> и <span class> и <a href> в register_sidebar

We need to uniqueize the selector for each widget. But so that in one widget the value of the selectors div id span class and a href match.
Tried <div id="%1$s"> и <div id="wgid">. But the uniqueness never happens.
-----
I think this is what I need dl2.joxi.net/drive/2016/04/09/0016/1202/1090738/38... Does anyone
know how the number is assigned and what variables are used? )

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Vorotnev, 2016-04-10
@HeadOnFire

In the screenshot, id="widget-13_text-5" is the WordPress generated id, which means you have the 13th widget, the 5th type of text widget. If you need to modify, make your own widget:

class My_Text_Widged extends WP_Widget {
    function __construct() {
        parent::__construct(
            'my_widget_id', // ID виджета
            __('Widget Title', 'text_domain'), // Name
            array( 'description' => __( 'My Widget', 'text_domain' ), ) // Args
        );
    }
}

Override other methods as needed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question