[Support request] When to call add_filters?

Home Forums Support When to call add_filters?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #361447
    Anthony

    Hello, I’m trying to remove author, date, category and tag from single posts (but keep them for archive pages).

    I don’t understand when to call the filters. I tried something like that but it doesn’t work. I guess the after_setup_theme is not the right action. Can you help ? Thank you

    /* Remove meta on single post */
    add_action( ‘after_setup_theme’, ‘remove_post_meta’ );
    function remove_post_meta() {
    if ( is_singular( ‘post’) ) {
    add_filter( ‘generate_post_author’, ‘__return_false’ );
    add_filter( ‘generate_post_date’, ‘__return_false’ );
    add_filter( ‘generate_show_categories’, ‘__return_false’ );
    add_filter( ‘generate_show_tags’, ‘__return_false’ );
    add_filter( ‘generate_show_comments’, ‘__return_false’ );
    }
    }

    GeneratePress 1.3.48
    GP Premium 1.3.1
    #361625
    Leo
    Staff
    Customer Support

    Hi there,

    Try this:

    add_action( 'wp','tu_remove_blog_meta' );
    function tu_remove_blog_meta() {
        if ( is_single() ) {
            add_filter( 'generate_post_date_output','__return_false' );
            add_filter( 'generate_post_author_output','__return_false' );
            add_filter( 'generate_category_list_output','__return_false' );
            add_filter( 'generate_tag_list_output','__return_false' );
            add_filter( 'generate_show_comments','__return_false' );
        }
    }

    Adding PHP: https://docs.generatepress.com/article/adding-php/

    #367839
    Rodrigo

    Hi, I have the same problem and tryed to use this snippet above, but it didn’t worked.
    I searched google and found this solution
    http://docs.layerswp.com/doc/how-to-turn-off-comments-or-reviews-on-single-posts-or-products/

    #367972
    Leo
    Staff
    Customer Support

    Hmm just tested the code and it’s working for me.

    How are you adding it currently?

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