Support » Plugins » Can anybody explain me what’s %1$s ???

  • Can you shortly explain me or lead me to the answer about how to access those variables with %#… ???

    I’d like to get widget number inside a sidebar (or TEXT widget instance inside that sidebar, since that sidebar will only contain text widgets), but I haven’t found info about those in the codex and the whole internet.

    WP codex uses this example, but both the id and class give me the basename plus the widget number. I only need the widget number, which I think is very useful.
    I tried $i, but it doesn’t do a thing.

    <?php $args = array(
    	'name'          => sprintf(__('Sidebar %d'), $i ),
    	'id'            => 'sidebar-$i',
    	'description'   => ''
    	'before_widget' => '<li id="%1$s" class="widget %2$s">',
    	'after_widget'  => '</li>',
    	'before_title'  => '<h2 class="widgettitle">',
    	'after_title'   => '</h2>' ); ?>
Viewing 1 replies (of 1 total)
  • esmi


    Forum Moderator

    %1$s is a text-substitution rather like a preg_replace. I’d suggest examining the register_sidebar function in wp-includes/widgets.php to see how the text substitution works.

Viewing 1 replies (of 1 total)
  • The topic ‘Can anybody explain me what’s %1$s ???’ is closed to new replies.