• Resolved erubiales

    (@erubiales)


    Is it possible to enable auto-notifications for posts published in a selected category?

    Using custom post types makes it very difficult to display the publications in Avada theme widgets.

    Regards.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author wpdever

    (@wpdever)

    Hi,

    To create notifications for posts in certain categories only, you can add this to your theme’s functions.php file:

    add_filter('wnbell_restrict_post_term','restrict_post_category',10,2);
     function restrict_post_category($allowed, $post_id){
    $categories = array('Some category', 'Another category');
    $post_categories = wp_get_post_categories( $post_id, array('fields' => 'ids') );
    $allowed = false;
    foreach($categories as $category){
    $cat_id = get_cat_ID($category);
    if(!$cat_id) continue;
    if(in_array($cat_id,$post_categories)){
    $allowed=true;
    break;
    }
    }
    return $allowed;
     } 

    and replace this with your categories:
    $categories = array(‘Some category’, ‘Another category’);

    For the custom post types, I’m not sure what you mean. I can’t test with this theme but let me know if there’s something I should fix.

    Thread Starter erubiales

    (@erubiales)

    Thank you very much for your fast support! Regards.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Post Category Notifications’ is closed to new replies.