How do I? foreach loop of categories
Hi
I wasn't sure where to post this question because it is more of a question regarding "how to" and I didn't find it in the documents.
I have a foreach loop:
$categories = get_categories( array( 'hide_empty' => '0' ) ); foreach ( $categories as $category ) { $name = $category->name; $slug = $category->slug; echo '<tr><td><label for="xf_category_forum_id_' . $slug . '">'; echo $name . ' </td>'; echo '<td><input name="xf_category_forum_id_' . $slug . '" type="text" maxlength="4" size="4" id="xf_category_forum_id_' . $slug . '" value="' . $xf_options['xf_category_forum_id'][ $slug ] . ' " /></td></tr>'; echo "</label><br />"; }
I'm trying to figure out how to replicate this in redux.
This is the label just before it.
<label for="xf_category_forum_id_default"> <td>Default</td> <td><input name="xf_category_forum_id_default" type="text" maxlength="4" size="4" id="xf_category_forum_id_default" value="<?php echo $xf_options['xf_category_forum_id']['default']; ?>"/></td> </label>
Now, the end result is the return of categories then the WP admin can add in a forum id next to the category. Since some installs only have 1 category then 1 textbox is returned. If 10 then 10 ...
If there are documents on foreach loops and this type of behavior then please let me know.

use the 'data'=>'categories' attribute as had in the docs. ;)
Thank you.
http://docs.reduxframework.com/redux-framework/fields/text/
No 'data' argument on that page but tried and it almost works. Not all of the categories are being returned. The categories without posts are not being returned.
array( 'id' => 'xf_category_forum_id', 'type' => 'text', 'title' => __('Enter the forum id', 'xenword_options'), 'desc' => __('The forum id may be found by hovering over the forum title.', 'xenword_options'), 'data' => 'categories', 'default' => '2' ),
There is no data argument doced for the text field, as - as far as I know - i t was never intended for use with the text field.
Either way, you want to use the args argument in your field code, to pass any of the arguments listed here: http://codex.wordpress.org/Function_Reference/get_categories. hide_empty to false, most likely.
Multi-Text supports that. That's what you're looking for. ;)