• Resolved pakpenyo

    (@pakpenyo)


    How do I exclude posts by author?

    This is not working:

                    'taxonomy'       => 'author',
    'term_id' => '-368',
    'stats_taxonomy' => 1,
    'stats_author' => 1,

    Am I missing something?

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

    (@hcabrera)

    Hey there,

    Did you create an author taxonomy or are you trying to exclude posts by WordPress user ID? If it’s the latter the plugin doesn’t currently provide a way to exclude authors by user ID.

    Thread Starter pakpenyo

    (@pakpenyo)

    I misunderstood. I thought author was a taxonomy when looking at the ‘wp_term_taxonomy’ table. For now, I’ve created a filter to exclude posts from an author.

    add_filter(
    'wp_script_attributes',
    function ( $atts ) {
    global $post;
    if (
    ( is_single() && $post->post_author == 54 ) // author_ID 54
    && ( str_contains( $atts['src'], 'wpp.js' ) || str_contains( $atts['src'], 'wpp.min.js' ) ) ) {
    $atts['src'] = '';
    }
    return $atts;
    },
    10,
    1
    );
Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.