[Resolved] Disable post Meta for certain authors

Home Forums Support [Resolved] Disable post Meta for certain authors

Home Forums Support Disable post Meta for certain authors

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #645261
    Carson

    I am trying to disable post meta for certain authors.
    Meaning, if author ID is “x”, I want no date, no name or any other meta to show up on the post itself as well as next to the preview in cetegory pages/wp show posts.

    Any ideas on how to achieve this?

    Also, is there a way to get author bios under posts without a third-party plugin by now?

    Thanks

    #645276
    Leo
    Staff
    Customer Support

    Hi there,

    – Try this filter:
    https://docs.generatepress.com/article/option_generate_blog_settings/

    Example is at the bottom of the page:
    https://docs.generatepress.com/article/option_generate_blog_settings/

    Conditional tags you will need:
    https://codex.wordpress.org/Conditional_Tags#An_Author_Page

    – As for author bio, should be able to use GP hooks:
    https://docs.generatepress.com/article/hooks-overview/

    with the similar conditional tags as above.

    I should also mention that Hooks Module will be replaced by Hooks Element in GP Premium 1.7 which should be released next Monday. My recommendation is to wait until Monday or becoming a beta tester (we are now on release candidate 3 so should be stable) so you can start using the new Hooks Element:
    https://docs.generatepress.com/article/hooks-element-overview/
    https://docs.generatepress.com/article/beta-testing/

    Let me know if this helps πŸ™‚

    #645567
    Carson
    add_filter( 'option_generate_blog_settings'{
        if ( is_author( '4' )  ) {
    	$options['read_more_button'] = true;
    	$options['date'] = false;
    	$options['categories'] = false;
    	$options['tags'] = false;
    	$options['comments'] = false;
        }
      
        return $options;
    }

    Like this?

    #645759
    Leo
    Staff
    Customer Support

    No that doesn’t look like the example at the bottom of the page.

    add_filter( 'option_generate_blog_settings', 'lh_custom_author_page_settings' );
    function lh_custom_author_page_settings( $options ) {
        if ( is_author( '4' )  ) {
    	$options['read_more_button'] = true;
    	$options['date'] = false;
    	$options['categories'] = false;
    	$options['tags'] = false;
    	$options['comments'] = false;
        }
      
        return $options;
    }

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

    #645930
    Carson

    This doesn’t work. It still shows the author on the article.

    To clarify:

    Ideally I don’t want to show any author/date on the article istself, as well as on any previews in categories etc.

    Code I am using right now:

    add_filter( 'option_generate_blog_settings', 'lh_custom_author_page_settings' );
    function lh_custom_author_page_settings( $options ) {
        if ( is_author( '3' )  ) {
    	$options['author'] = false;
    	$options['date'] = false;
    	$options['categories'] = false;
    	$options['tags'] = false;
        }
      
        return $options;
    }
    #646024
    Leo
    Staff
    Customer Support

    That should work for the archive/blog page.

    For the article itself you will need the single_ filters like this:
    https://docs.generatepress.com/article/option_generate_blog_settings/#options-%E2%80%98single_author%E2%80%99

    #646174
    Carson

    It still doesnt work. The domain.com/category/xxxx page as well as the posts of the author with the ID 3, still show “by xxxxx”.

    
    add_filter( 'option_generate_blog_settings', 'lh_custom_author_page_settings' );
    function lh_custom_author_page_settings( $options ) {
        if ( is_author( '3' )  ) {
    	$options['author'] = false;
    	$options['single_author'] = false;
    	$options['date'] = false;
    	$options['categories'] = false;
    	$options['tags'] = false;
        }
      
        return $options;
    }
    #646416
    Tom
    Lead Developer
    Lead Developer

    Try this instead:

    add_filter( 'option_generate_blog_settings', 'lh_custom_author_page_settings' );
    function lh_custom_author_page_settings( $options ) {
        $author = get_the_author_meta( 'ID' );
    
        if ( 3 === $author ) {
    	$options['author'] = false;
    	$options['single_author'] = false;
    	$options['date'] = false;
    	$options['categories'] = false;
    	$options['tags'] = false;
        }
      
        return $options;
    }

    Let me know πŸ™‚

    #646570
    Carson

    Thanks a lot that works great!

    So regarding the author boxes below posts, what code snippet do I have to add? And once hook elements is out it’s still the same snippet right?

    Thanks again!

    #646583
    Leo
    Staff
    Customer Support

    I believe we’d have to use this filter:
    https://docs.generatepress.com/article/generate_hook_element_display/

    Can you open a new topic for this separate question?

    It might be come in handy in the future πŸ™‚

    Thanks!

    #646734
    Carson

    Sure!

    #647033
    Leo
    Staff
    Customer Support

    Thanks πŸ™‚

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