Support » Plugin: Recent Posts with Excerpts » [Plugin: Recent Posts with Excerpts] Exclude categories and tags

  • Resolved JGeo


    I wanted to use this plugin with the option to exclude certain categories and tags. I modified the code. Maybe this could be added to a future version, so I won’t need forked code on my site. And to help others of course.

    I commented-out those lines:

    // retrieve last n blog posts
    $q = 'showposts='.$instance['numposts'];

    until just before
    and replaced it by

    $extag = get_query_var('tag_id');
    $intag = get_query_var('tag_id');
    $q = array(

    Furthermore, I added after the lines

    $instance['cat'] = $new_instance['cat'];
    $instance['tag'] = $new_instance['tag'];

    those new lines:

    $instance['excat'] = $new_instance['excat'];
    $instance['extag'] = $new_instance['extag'];

    And after the line
    <?php wp_dropdown_categories...
    I added the lines

    <p><label for="<?php echo $this->get_field_id('excat'); ?>"><?php _e('Exclude category: '); ?><br />
    <?php wp_dropdown_categories(array('name' => $this->get_field_name('excat'), 'show_option_all' => __('Exclude none'), 'hide_empty'=>0, 'hierarchical'=>1, 'selected'=>$instance['excat'])); ?></label></p>

    and after

    <br /><small><?php _e('Enter post tags separated by commas (\'cat,dog\')'); ?></small>

    I added

    <label for="<?php echo $this->get_field_id('extag'); ?>"><?php _e('Exclude tags:'); ?></label>
    <input class="widefat" id="<?php echo $this->get_field_id('extag'); ?>" name="<?php echo $this->get_field_name('extag'); ?>" type="text" value="<?php echo $instance['extag']; ?>" />

    That was all.

  • The topic ‘[Plugin: Recent Posts with Excerpts] Exclude categories and tags’ is closed to new replies.