• Resolved cobajashi

    (@cobajashi)


    Hi,

    Is there any way to set automatic activation by category with your plugin?

    Our problem is that dynamic content and ACF/SCF fields need to be called. This would break the whole layout. We are interested in the lifetime license.

    Thanks in advance.

Viewing 1 replies (of 1 total)
  • Plugin Support Michael

    (@wpjmike)

    Hi,

    If you want to use the auto insert by category, you can achieve that using the built-in hooks

    Example below to activate the auto-insert on category “dogs” only:

    add_filter('joli_toc_disable_toc_custom', 'toc_disable', 10, 3);

    function toc_disable($value, $content, $post)
    {
    // Retrieve an array of category objects for the current post
    $cats_array = get_the_category($post->ID);

    //Keep the slug only
    $post_categories = wp_list_pluck($cats_array, 'slug');

    //TOC will be disabled if the post is not of category "dogs", so the auto-insert will work only on category "dogs"
    if (!in_array('dogs', $post_categories)) {
    return true; //true to disable
    }

    //default to false
    return $value;
    }

    I will however take note of your suggestion and try to make it easier to adjust from the settings in a future update.

    Thank you!

Viewing 1 replies (of 1 total)

The topic ‘Set automatic activation by category’ is closed to new replies.