• Resolved gtaranti

    (@gtaranti)


    Is it possible to add another option to the crp_default_options array through a filter?

    I mean like that :

    function set_crp_post_type($crp_settings) {
    
        $crp_settings['post_type'] = 'recipe';
        return $crp_settings;
    
    }
    add_filter('crp_default_options', 'set_crp_post_type');
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Ajay

    (@ajay)

    Yes – That would work. Note that would only apply if you reset the options – This will not automatically display options in the settings page.

    That’s something I will be releasing in the next major version of the plugin

    Thread Starter gtaranti

    (@gtaranti)

    Sorry, I cannot make it work.
    Adding the crp_default_options filter doesn’t seem to have any effect. Even if I change something that is already in the $crp_settings array, (like $crp_settings['random_order'] = true; return $crp_settings;).

    By “..reset the options..” you mean to click on the “Default Options” button on the bottom of the plugin settings page?

    A little help here would be very much appreciated!

    Thread Starter gtaranti

    (@gtaranti)

    Never mind, I didn’t use the add_filter('crp_default_options') hook.
    I used excluded_categories option in the shortcode to obtain a similar effect.

    Something that I stumbled over with this method, is that because I’m using the crp_custom_template filter, I had to convert the exploded array of categories to int values, in order to work. Like that:

    
    $exclude_categories = array_map( 'intval', explode( ',', $args['exclude_categories']));
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Filter on crp_default_options’ is closed to new replies.