Hi guys,
I have been tinkering with your awesome activello theme on xampp and had some questions about how to best implement guest-authors. I was wondering if you could help me with this. We are running a magazine site where the admin will post articles written by other people. I currently use the custom field key ‘guest-author’ to achieve this. For implementation, I have put the following code in functions.php in a child-theme:
/** * Replaces authors with 'guest-author' custom field if present. */ add_filter( 'the_author', 'guest_author_name' ); add_filter( 'get_the_author_display_name', 'guest_author_name' );function guest_author_name( $name ) {
global $post;$author = get_post_meta( $post->ID, ‘guest-author’, true );
if ( $author )
$name = $author;return $name;
}
This replaces the ‘author’ with ‘guest-author’ in the dashboard, which allows admins to see at a glance which posts have which guest-author, and which do not have a guest-author at all (they may have forgotten to enter one). It also shows the ‘guest-author’ in place of ‘author’ (which is often the admin) on the feed. Which is handy, because if a reader has a favorite author he can see directly which posts are by the author he likes. But I would like to use a different custom field for this, namely ‘feed-author’, because this information will display in the feed. Do I just replace all instances of guest_author with feed_author?
Now, in the single post view, I would like to display some meta data as well. However sometimes a post will have an accompanying video or image which needs to be credited. Or sometimes, I will need to credit the guest-author as text-creator, instead of the principal author, because the content is a collaborative project by a writer and a illustrator. In some cases, there will be a translator which needs to be displayed.
I have been thinking about the best way to structure this information and I have thought of the follow custom fields:
‘feed-author’ -> this would take the place of ‘guest-author’ in the code-example displayed above. it would show in the dashboard and in the feed, and we can determine what information we would like readers to see at a glance.
‘general-author’ -> this would display in the single post view as ‘By: %general-author%’
‘image-author’ -> this would display in the single post view as ‘Image by: %image-author%’
‘video-author’ -> Ibid.
‘photo-author’ -> Ibid.
‘text-author’ -> Ibid.
‘translator’ -> 'Translated by: %translator%
So the output in single-post view could look like many possibilities:
“TITLE OF POST”
By: %general-author% / Image by: %image-author%
or
Image by: %image-author% / Sound by: %sound-author%
or
Text by: %text-author% / Video by: %video-author%
or
By: %general-author% / Photo by: %photo-author% / Sound by: %sound-creator%
or
By: %general-author% / Translation by: %translator%
etc.
So to summarize:
-
How to change the example code for usage with the custom field ‘feed-author’ instead of ‘guest-author’? Do I just search and replace?
-
How to display the chosen metadata under the title in single post view, where the metadata is displayed on a single line and in various possible combinations, depending on which custom fields have values, separated by a slash or other symbol.
Well, this is a pretty long question. I hope you are able to help me with this. In any case, thanks for your time and consideration.