- This topic has 10 replies, 3 voices, and was last updated 1 year, 10 months ago by David.
-
AuthorPosts
-
May 26, 2022 at 12:56 am #2233051Shaun
Hi
I have two different queries about blog posts on a website I am building.
1. Author Bio Boxes
I am setting up a website. Different people will write blog posts. I have created a GP Element (Block, After Content, Posts [see attached]) for an Author bio block. But I need to specify that only articles written by author X, show an author X bio block. Then only articles written by Author Y show an Author Y bia box etc. How can I do this?2. Previous article links
At the bottom of the articles are some meta links to the next/previous article (see attached). How do I remove the?May 26, 2022 at 12:58 am #2233054ShaunThe image URL didn’t work, but you see both the author box and bottom meta at the bottom of the link I shared in the Private Information field
May 26, 2022 at 1:39 am #2233095Fernando Customer SupportHi Shaun,
1. This is possible through a PHP snippet. Here is an article you may refer to: https://docs.generatepress.com/article/generate_element_display/#display-an-element-to-a-specific-author
A sample code would be:
add_filter( 'generate_block_element_display', function( $display, $element_id ) { $author_id = get_post_field( 'post_author', get_the_ID() ); if ( 394755 === $element_id && '1' == $author_id && is_single() ) { $display = true; } else if ( 394755 === $element_id && ‘1’ == $author_id && is_single() ) { $display = false; } return $display; }, 15, 2 );
Adding PHP reference: https://docs.generatepress.com/article/adding-php/#code-snippets
Kindly replace
394755
with the Element ID and1
with the author ID.2. Which are you planning to remove? The sentence seems cut off.
Kindly let us know.
May 26, 2022 at 6:22 pm #2234506ShaunThanks Fernando
Re issue 1 (the author bio element)
I have two queries
1a. I added the sample code to https://holidayparks.websmall.net/forest-flying-finch-hatton-gorge/ and my author bio element shows.
Yet it still shows for another user (still me but as a separate Admin user) see https://holidayparks.websmall.net/blacks-beach-mackay/
1b. Do I repeat the code you gave me for each author?Re Issue 2
Sorry – my question was cut off. I want to remove the next/previous meta – see (https://drive.google.com/file/d/1qw1S5OGiHoleG9sb79xeHMwdkWFPsHif/view?usp=sharing)
you can also see the meta at the bottom of the two blog posts I shared in issue 1.Thanks
ShaunMay 27, 2022 at 2:42 am #2234909DavidStaffCustomer SupportHi there,
on the author box… the Method that Fernando provided assumes you have a separate block element for each author.
Question – will the various authors have their own user profile? As if they do you should be able to use 1 dynamic block element for all of them. Let me know.
May 27, 2022 at 6:57 pm #2235792ShaunHi David
Thx for your response.
Yes, the different Authors will have their own user profile.
Cheers
ShaunMay 28, 2022 at 10:35 am #2236328DavidStaffCustomer SupportThis video explains how to add a dynamic author box, that method would mean one Element for all authors.
https://www.youtube.com/watch?v=4x6CjGOyagc&t=9s
May 28, 2022 at 3:15 pm #2236454ShaunThx David
Other than GP being a great product, you and the rest of the support team offer far better service than I have received anywhere else.
Do you have any advice regarding removing the Next post meta at the bottom of each post as above?May 29, 2022 at 5:33 am #2236765DavidStaffCustomer SupportThank you 🙂
You can use a PHP Snippet to remove just that item.
add_filter( 'generate_header_entry_meta_items', function( $items ) { return array_diff( $items, array( 'post-navigation' ) ); } );
OR if you’re using a Block Element to create your Post Meta:
https://docs.generatepress.com/article/block-element-post-meta-template/
When you select
After Content
you have the option to replace the theme secondary meta which includes the categories and post navigation.
So you can, if it works for your layout, create a footer meta with your Author box, and any other meta to replace the existing theme one.May 29, 2022 at 3:57 pm #2237276ShaunThx David
May 30, 2022 at 1:39 am #2237641DavidStaffCustomer SupportYou’re welcome
-
AuthorPosts
- You must be logged in to reply to this topic.