Support » Plugin: Simple Custom Post Order » Enable Post Order programmatically

  • Resolved iignacio

    (@iignacio)


    Hey,

    Is there a way to enable post order (options-general.php?page=scporder-settings) programmatically, for a certain post type?

    I’d like to enable SCP for taxonomies via functions.php for example.

    Thanks

    • This topic was modified 2 months, 2 weeks ago by iignacio.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support mplusb

    (@mplusb)

    Hello @iignacio,

    You can do this by filtering get_option: https://codex.wordpress.org/Plugin_API/Filter_Reference/option_(option_name)
    The option’s name where they are stored is: scporder_options
    which is an array and in ‘objects’ will keep all the custom posts and in ‘tags’ the taxonomies.

    All the best,
    Mihaela

    • This reply was modified 2 months, 2 weeks ago by mplusb.

    Hi @mplusb, thanks for your quick reply.

    After digging into the plugin’s code I ended up doing what you suggest. Here’s the code in case someone finds it useful.

    if (is_plugin_active('simple-custom-post-order/simple-custom-post-order.php')) {
        if (!get_option('scporder_options')) {
            update_option('scporder_options', array('objects' => '', 'tags' => array('category')));
        }
    }

    Would it make sense to have a function set this programmatically?
    Like scp_enable('tags' => array('category'))

    Thanks again!

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