Add an exclude Posts from categories Field for Widgets….

Posted in: Newspaper
Post count: 25

Please can you add the ‘category__not_in’ field for each component because I don’t want to overwrite your stuff each time.
Regards,

ex:

class td_slide extends td_block {

    function __construct() {
        $this->block_id = 'td_slide';
        add_shortcode('td_slide', array($this, 'render'));
    }
   function render($atts){
        $this->block_uid = td_global::td_generate_unique_id(); //update unique id on each render

        extract(shortcode_atts(
            array(
                'limit' => 5,
                'sort' => '',
                'category_id' => '',
                'category_ids' => '',
                'category__not_in' => '',
....

    function get_map () {

        //get the generic filter array
        $generic_filter_array = td_generic_filter_array::get_array();

        //add custom filter fields to generic filter array
        array_push ($generic_filter_array, 
            +array(
            +    "param_name" => "category__not_in",
            +    "type" => "textfield",
            +    "value" => '',
            +    "heading" => "Exclude posts from categories id (, separated)",
            +    "description" => "",
            +    "holder" => "div",
            +    "class" => ""
            +),

In td_data_source


class td_data_source {

    static $fake_loop_offset = 0; //used by the found row hook in templates to fix pagination. The blocks do not use this since we use custom pagination there.

    /**
     * converts a pagebuilde array to a wordpress query args array
     * creates the $args array from shortcodes - used by the pagebuilde + widgets + by the metabox_to_args
     * @param string $atts : the shortcode string
     * @param string $paged : page number  /1  or  /2
     * @return array
     */
    static function shortcode_to_args($atts = '', $paged = '') {
        extract(shortcode_atts(
                array(
                    'category_ids' => '',
                    'category_id' => '',
                    + 'category__not_in' => '',
...}

        if (!empty($category__not_in)) {
            $wp_query_args['category__not_in'] = explode(',', $category__not_in);
        }
Post count: 6600

Hi,

Thanks, I have added this on our list and we will consider this for future updates, until then you can do this by adding -77 to exclude posts from a specific category, add with minus sign the category ID you want to exclude.

Thanks

Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.