Note that there are some explanatory texts on larger screens.

plurals
  1. POCan I change ID's, names and values within loop
    text
    copied!<p>i am working in wordpress and little confused.</p> <p>with the help of loop I created 9 lists but I am not understanding how can I change the value, id and name of each input field.</p> <pre><code>&lt;?php echo $this-&gt;get_field_id( 'tab1_thumb' ); ?&gt; </code></pre> <p>how can i change <strong>tab1_thumb</strong> for each li</p> <pre><code>&lt;ul&gt; &lt;?php $i = 1; while ($i &lt;= 9) { ?&gt; &lt;li style="border: 1px solid #ddd; padding: 15px;"&gt; &lt;p&gt;&lt;strong&gt;&lt;?php echo 'Tab 0'.$i; ?&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;?php _e('Thumbnail: '); ?&gt;&lt;/strong&gt;&lt;input type="text" id="&lt;?php echo $this-&gt;get_field_id( 'tab1_thumb' ); ?&gt;" name="&lt;?php echo $this-&gt;get_field_name( 'tab1_thumb' ); ?&gt;" value="&lt;?php echo $instance['tab1_thumb']; ?&gt;" class="widefat" /&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;?php _e('Featured Image: '); ?&gt;&lt;/strong&gt;&lt;input type="text" id="&lt;?php echo $this-&gt;get_field_id( 'tab1_featured' ); ?&gt;" name="&lt;?php echo $this-&gt;get_field_name( 'tab1_featured' ); ?&gt;" value="&lt;?php echo $instance['tab1_featured']; ?&gt;" class="widefat" /&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;?php _e('Category: '); ?&gt;&lt;/strong&gt; &lt;?php wp_dropdown_categories(array('name' =&gt; $this-&gt;get_field_name('tab1_cat_name'), 'selected' =&gt; $instance['tab1_cat_name'], 'orderby' =&gt; 'Name' , 'hierarchical' =&gt; 1, 'show_option_all' =&gt; '', 'hide_empty' =&gt; '0', 'taxonomy' =&gt; 'product_cat')); ?&gt;&lt;/label&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;?php _e('Description: '); ?&gt;&lt;/strong&gt;&lt;br&gt; &lt;textarea class="widefat" id="&lt;?php echo $this-&gt;get_field_id('tab1_description'); ?&gt;" name="&lt;?php echo $this-&gt;get_field_name('tab1_description'); ?&gt;" type="text"&gt;&lt;/textarea&gt;&lt;/p&gt; &lt;/li&gt; &lt;?php $i += 1; } ?&gt; &lt;/ul&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload