имеется тема – magazine-basic, которой используется виджет ‘Feature Post". К сожалению возможность его использовать только один раз. А я хочу чтобы можно было использовать этот виджет несколько раз.
Как переделать его в мульти?
<?php
function widget_sideFeature2() {
$options = get_option("widget_sideFeature2");
$numberOf = $options['number'];
$category = $options['category'];
$category = "&cat=" . $category;
$showposts = "showposts=" . $numberOf . $category ;
?>
<?php
$featuredPosts = new WP_Query();
$featuredPosts->query($showposts);
?>
<?php $i = 1; ?>
<?php while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); ?>
<h1 class="side"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
<div class="meta">
By <?php the_author() ?>
</div>
<div class="storycontent <?php if($numberOf == $i) { echo "noline"; } $i++; ?>">
<?php theme_excerpt('25'); ?>
</div>
<?php
endwhile;
}
function widget_myFeature2($args) {
extract($args);
$options = get_option("widget_sideFeature2");
echo $before_widget;
echo $before_title;
echo $options['title'];
echo $after_title;
widget_sideFeature2();
echo $after_widget;
}
function myFeature2_control()
{
$options = get_option("widget_sideFeature2");
if (!is_array( $options ))
{
$options = array(
'title' => 'Feature',
'number' => '1',
'category' => '0'
);
}
if ($_POST['sideFeature2-Submit'])
{
$options['title'] = htmlspecialchars($_POST['sideFeature2-WidgetTitle']);
$options['number'] = htmlspecialchars($_POST['sideFeature2-PostNumber']);
if ( $options['number'] > 5) { $options['number'] = 5; }
$options['category'] = htmlspecialchars($_POST['sideFeature2-Category']);
update_option("widget_sideFeature2", $options);
}
?>
<p>
<label for="sideFeature2-WidgetTitle">Title: </label><br />
<input class="widefat" type="text" id="sideFeature2-WidgetTitle" name="sideFeature2-WidgetTitle" value="<?php echo $options['title'];?>" />
<br /><br />
<label for="sideFeature2-PostNumber">Number of posts to show: </label>
<input type="text" id="sideFeature2-PostNumber" name="sideFeature2-PostNumber" style="width: 25px; text-align: center;" maxlength="1" value="<?php echo $options['number'];?>" /><br />
<small><em>(max 5)</em></small>
<br /><br />
<label for="sideFeature2-Category">From which category: </label>
<?php
$options = get_option("widget_sideFeature2");
$category = $options['category'];
?>
<?php wp_dropdown_categories('name=sideFeature2-Category&selected='.$category); ?>
<input type="hidden" id="sideFeature2-Submit" name="sideFeature2-Submit" value="1" />
<p><small><em>(Note: The selected will be excluded from the main content on the index page)</em></small></p>
</p>
<?php
}
register_sidebar_widget( 'Featured Post', 'widget_myFeature2');
register_widget_control( 'Featured Post', 'myFeature2_control');
?>