jorge ocampo
asked 10 years ago

I’m a brand new customer, i bought Argo because i thought i would be able to filter the post in the METRO area (using a specific TAG, CATEGORY or else)
The theme is great, but is not useful for me if there’s no way to solve this, i’m agree to switch my license to Focus Theme if there is a chance
Thank you 
 
 

2 Answers
Kido D
answered 10 years ago

Hi Jorge,
Please try out our solution here, if still impossible to solve your issue, we will switch theme license for you.
To add the Metro content filter to Argo theme, you can copy/paste the code in 2 files here to the corresponding files in dw-argo theme:

feature-metro-layout.php (in theme/dw-argo folder)
theme-customization.php (in theme/dw-argo/inc folder)

Then you will have the Metro content filter in Dashboard / Appearance / Customize:


 
Or if you want to modify the files manually, please following the steps below:
 
1, Open up the theme-customization.php file in dw-argo/inc folder, find the following code (around line 143)

// METRO GRID COLORS
$wp_customize->add_section('dw_argo_metro_color', array(
'title' => __('Metro Grid Colors', 'dw-argo'),
'priority' => 105,
));

Then, add the code below right above it:

// METRO FILTER
$wp_customize->add_section('dw_argo_metro_filter', array(
'title' => __('Metro Filter', 'dw-argo'),
'priority' => 104,
));
$wp_customize->add_setting('dw_theme_options[metro_cat]', array(
'capability' => 'edit_theme_options',
'type' => 'option',
));
$wp_customize->add_control( new WP_Cats_Select_Control($wp_customize, 'metro_cat', array(
'label' => __('Select Categories','dw-argo'),
'section' => 'dw_argo_metro_filter',
'settings' => 'dw_theme_options[metro_cat]'
)));
$wp_customize->add_setting('dw_theme_options[metro_tag]', array(
'capability' => 'edit_theme_options',
'type' => 'option',
));
$wp_customize->add_control( new WP_Tags_Select_Control($wp_customize, 'metro_tag', array(
'label' => __('Select Tags','dw-argo'),
'section' => 'dw_argo_metro_filter',
'settings' => 'dw_theme_options[metro_tag]'
)));
$wp_customize->add_setting('dw_theme_options[metro_order]', array(
'capability' => 'edit_theme_options',
'type' => 'option',
));
$wp_customize->add_control( new WP_Orders_Select_Control($wp_customize, 'metro_order', array(
'label' => __('Order by','dw-argo'),
'section' => 'dw_argo_metro_filter',
'settings' => 'dw_theme_options[metro_order]'
)));

 
2, Still in the theme-customization.php file, find the ‘Color_Picker_Custom_control‘ class (somewhere at top of the file), then add 3 classes below right under it:

class WP_Cats_Select_Control extends WP_Customize_Control {
public function render_content() {
$cats = get_categories();
?>
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
<select multiple style="height: auto" <?php echo $this->get_link() ?> >
<option value="-1" selected><?php _e('- All Categories -','dw-argo') ?></option>
<?php foreach ($cats as $key => $value) { ?>
<option value="<?php echo esc_attr( $value->term_id ); ?>"><?php echo esc_html($value->name) ?></option>
<?php } ?>
</select>
<?php
}
}
class WP_Tags_Select_Control extends WP_Customize_Control {
public function render_content() {
$tags = get_tags();
?>
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
<select multiple style="height: auto" <?php echo $this->get_link() ?> >
<option value="-1" selected><?php _e('- All tags -','dw-argo') ?></option>
<?php foreach ($tags as $key => $value) { ?>
<option value="<?php echo esc_attr( $value->term_id ); ?>"><?php echo esc_html($value->name) ?></option>
<?php } ?>
</select>
<?php
}
}
class WP_Orders_Select_Control extends WP_Customize_Control {
public function render_content() {
$tags = get_tags();
?>
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
<select style="height: auto" <?php echo $this->get_link() ?> >
<option value=""><?php _e('- None -','dw-argo') ?></option>
<option value="title"><?php _e('Title','dw-argo') ?></option>
<option value="date"><?php _e('Latest','dw-argo') ?></option>
<option value="comment_count"><?php _e('Popular','dw-argo') ?></option>
<option value="rand"><?php _e('Random','dw-argo') ?></option>
</select>
<?php
}
}

3, Open up the feature-metro-layout.php file in dw-argo theme folder, find the following code (at the very first of the file):

$metro_query = new WP_Query( 'posts_per_page=6' );

Then, replace that line with the code below:

$metro_args = array();
$metro_args['posts_per_page'] = 6;
if(dw_get_theme_option('metro_order')) {
$metro_args['orderby'] = dw_get_theme_option('metro_order');
if($metro_args['orderby'] == 'title') {
$metro_args['order'] = 'ASC';
} else {
$metro_args['order'] = 'DESC';
}
}
$metro_cat = dw_get_theme_option('metro_cat');
if( isset($metro_cat[0]) && $metro_cat[0] > 0 ) {
$metro_args['category__in'] = $metro_cat;
}
$metro_tag = dw_get_theme_option('metro_tag');
if( isset($metro_tag[0]) && $metro_tag[0] > 0 ) {
$metro_args['tag__in'] = $metro_tag;
}
$metro_query = new WP_Query( $metro_args );

Hope that helps!

jorge ocampo
answered 10 years ago

Great, thank you for your answer Kido

Powered by DW Question & Answer Pro