Daniel Albrecht
asked 10 years ago

Hi!
In the News Slider widget there is a dropdown menu to choose a “category”.
Would it be possible to add another dropdown menu to choose featured posts using a “tag”.
Best, Daniel
 
 

3 Answers
Wilfred
answered 10 years ago

Hi Daniel Albrecht,
To resolve this issue please follow my instruction here:
1. Open file dw-focus-slider.php in your site / wp-content / themes / your theme / inc / widgets/ dw-focus-slider.php
2. Replace bellow code – line 46

'cat'              => $instance['category'],

with this code

// 'cat' => $instance['category'],
'tag' => $instance['tags'],

3. Replace bellow code – line 178 

$instance['category'] = (int) $new_instance['category'];

with

// $instance['category'] = (int) $new_instance['category'];
$instance['tags'] = $new_instance['tags'];

4. Replace bellow code – line 200 

$category = isset($instance['category']) ? absint($instance['category']) : 0;

with

// $category = isset($instance['category']) ? absint($instance['category']) : 0;
$tags = isset($instance['tags']) ? esc_attr($instance['tags']) : '';

5. Replace bellow code – from line 200 to line 226

<p><label for="<?php echo $this->get_field_id('category'); ?>"><?php _e('Category:','dw_focus'); ?></label><br>
<?php wp_dropdown_categories(array(
'show_option_all' => 'All categories',
'hide_empty' => 0,
'id' => $this->get_field_id('category'),
'name' => $this->get_field_name('category'),
'selected' => $category,
'class' => 'widefat',
'hierarchical' => true,
'walker' => new DW_Walker_CategoryDropdown()
) ); ?>
</p>

with

<!-- <p><label for="<?php echo $this->get_field_id('category'); ?>"><?php _e('Category:','dw_focus'); ?></label><br>
<?php wp_dropdown_categories(array(
'show_option_all' => 'All categories',
'hide_empty' => 0,
'id' => $this->get_field_id('category'),
'name' => $this->get_field_name('category'),
'selected' => $category,
'class' => 'widefat',
'hierarchical' => true,
'walker' => new DW_Walker_CategoryDropdown()
) ); ?>
</p> -->
<p><label for="<?php echo $this->get_field_id('tags'); ?>"><?php _e('Tags:', 'dw_focus' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('tags'); ?>" name="<?php echo $this->get_field_name('tags'); ?>" type="text" value="<?php echo $tags; ?>" /></p>

6. Open file custom.js in your site / wp-content / themes / your theme / assets / js / custom.js
Replace bellow code – from line 33to line 40

for( var key in navs ){
if( navs[key].length > 0 ){
navs[key].find('li').each(function(){
$(this).removeClass('active');
});
navs[key].find('li').eq(index).addClass('active');
}
}

with 

for( var i = 0; i < navs.length; i++){
if( navs[i].length > 0 ){
navs[i].find('li').each(function(){
$(this).removeClass('active');
});
navs[i].find('li').eq(index).addClass('active');
}
}

7. To query by the tag you please add tags as below image:

Hope this helps!

DominicStaff
answered 10 years ago

Hello Daniel !
Thanks for your suggestion. We do not have this feature at the moment but will discuss and add it  in the next version.

Stefano Bergomas
replied 9 years ago

Wonderful, waiting for it! 🙂

Keith Lucas
answered 10 years ago

This would help me also, do you have an ETA yet?

Powered by DW Question & Answer Pro