Site logo

Archived topic

Disable post Meta for certain authors

11 replies · Started by Carson on August 10, 2018

Viewing posts 1–12 of 12

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

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 :)

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?

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/

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;
}

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;
}

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 :)

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!

Sure!

Thanks :)

This archived topic is closed to new replies.