Hi - I need to convert the wordpress function:
<?php the_author_posts_link(); ?>
into a shortcode. It displays the name of the author and links to their other posts.
I’ve gotten this far in the functions.php file:
function author_shortcode() {
return the_author_posts_link();
}
add_shortcode( ‘author’, ‘author_shortcode’ );
This works. I can enter the shortcode [author] into wordpress edit window for page, and it displays the author. Now my problem is I need a “by” before the author name, and I need it right-aligned.
This is how it should look (which was built into the theme) - author’s name as first block on post, right-aligned, with a “by” before it:
https://dev.greensmoothie.com/blend/energy
This is how it looks as my shortcode on a page (wrong) - the theme does not have any option to display author’s name on a page, only on a post. That’s why I have to do it in functions.php for pages:
https://dev.greensmoothie.com/
How do I add in the php a “by” before: return the_author_posts_link();
and how do I tell it to display that return as right-aligned?
Sorry my php knowledge is nearly zero. It took me hours to find that working php to convert a wordpress function into a shortcode. Thank you!