- This topic has 15 replies, 5 voices, and was last updated 4 years, 9 months ago by Leo.
-
AuthorPosts
-
May 28, 2019 at 2:27 am #912962Emma
Hi,
I’d like to know if there is a way to have the author name at the bottom of each article instead of at the top?
Thanks.
May 28, 2019 at 3:43 am #913028DavidStaffCustomer SupportHi there,
we could use a hook to add that in – which is what i did here to add the author box:
https://gpsites.co/volume/sample-post/
Let me know if thats something you would like or just the author name.
May 28, 2019 at 3:53 am #913041EmmaThanks, I’m just looking to move the author name so it just says ‘by name’ at the bottom of the post instead of at the top if that’s possible?
May 28, 2019 at 4:57 am #913105DavidStaffCustomer SupportSo create a new Hook Element:
https://docs.generatepress.com/article/hooks-element-overview/
Give it a title and add this content:
<span class="author-name" itemprop="name"><?php printf( esc_attr__( 'by %s', 'the author' ), get_the_author_meta( 'display_name') );?></span>
Select the
after_content
hook.
Check execute PHP
Set the priority to 0
Then set the display rules to Posts > All PostsMay 28, 2019 at 6:02 am #913145EmmaOk, thank you, will try this. Is there a way to do it by just adding some php code without using hooks? I managed to move the categories on the post archives with some code that I copied and pasted (I use the code snippets plugin)… Is that possible at all rather than using a hook or is that the only way to do it?
May 28, 2019 at 6:09 am #913160DavidStaffCustomer SupportIts more complicated, but yes you can use the
add_action
function:https://docs.generatepress.com/article/using-hooks/#usage
With a conditional tag to specify the single post:
https://docs.generatepress.com/article/using-hooks-conditional-tags/#single-posts
So your code would look something like this:
add_action( 'generate_after_content','db_after_post_author' ); function db_after_post_author() { if ( is_single() ) : ?> <span class="author-name" itemprop="name"><?php printf( esc_attr__( 'by %s', 'the author' ), get_the_author_meta( 'display_name') );?></span> <?php endif; }
The Hook Element is so less messy π
May 28, 2019 at 11:24 am #913622EmmaThis doesn’t seem to work, I will try it the other way with the hook. Thanks
May 28, 2019 at 3:44 pm #913797TomLead DeveloperLead DeveloperIf you’re able to try 2.3 (currently in alpha), we can try the new post meta ordering system?: https://generatepress.com/generatepress-2-3/
Let me know π
May 30, 2019 at 3:59 am #915134EmmaYes, I would be interested in trying it. I should be very simple what I want to do as I just want the author name at the bottom of the post π
May 30, 2019 at 8:23 am #915458TomLead DeveloperLead DeveloperCool – let me know if you install it and I’ll provide the code π
June 21, 2019 at 1:09 am #936642EmmaI have the latest version installed now and I would like the code to do this. Thanks.
June 21, 2019 at 8:37 am #937141TomLead DeveloperLead DeveloperLet’s try this:
add_filter( 'generate_header_entry_meta_items', function( $items ) { return array_diff( $items, [ 'author' ] ); } ); add_filter( 'generate_footer_entry_meta_items', function( $items ) { $items[] = 'author'; return $items; } );
Let me know π
June 28, 2019 at 1:59 am #943590EmmaThanks for this, works great. It is possible for the author to go above the category? At the moment it is at the bottom of the post but it is in between the category and the post navigation… Thanks
June 28, 2019 at 12:14 pm #944137TomLead DeveloperLead DeveloperDefinitely, replace the second filter above with this one:
add_filter( 'generate_footer_entry_meta_items', function( $items ) { array_unshift( $items, 'author' ); return $items; } );
Let me know π
July 2, 2019 at 7:49 pm #947555CurtHi Tom,
Sorry, I’m not well versed in code. Where is that you actually install that snippet you posted above?Thanks.
-
AuthorPosts
- You must be logged in to reply to this topic.