Mauer Themes › Support › Narrator › Show post author?
Tagged: post author publishpress-authors
- This topic has 19 replies, 6 voices, and was last updated 1 month ago by
Paul.
-
AuthorPosts
-
October 29, 2018 at 1:51 am #2936
zs2018
ParticipantHello — this is a fantastic, clean theme. I have installed it and successfully set it up – the guide was helpful and well written.
However, I do not see the author of each post shown anywhere. Is there a way to display the post author? Currently all posts seem author-less or anonymous. I hope this is something that can be done or that you are considering implementing. Thanks.
November 4, 2018 at 6:15 pm #2982Paul
KeymasterHello,
Thanks for your kind words about Narrator.
The theme does not output the post author anywhere. You can either use a plugin to do that (may require additional styling to blend into the looks of the theme), or if you just want to display the name of the author, you can do the following:
To display author name on the single blog post page, in your Admin Panel please go to ‘Appearance’ -> ‘Editor’, find the functions.php file on the right, and add the following code at the end of the file — just before the closing
?>
. Feel free to change thePost by:
text.if (!function_exists('mauer_append_post_author_name')) : function mauer_append_post_author_name($content) { if(is_singular() && is_main_query()) { ob_start(); ?> <p><i>Post by: <?php the_author(); ?></i></p> <?php $new_content = ob_get_clean(); $content .= $new_content; } return $content; } endif; add_filter('the_content', 'mauer_append_post_author_name', 1, 5);
The end result should look like his: screenshot.
Click the ‘Update file’ button.
Regards,
PaulNovember 20, 2018 at 7:16 pm #3027ingak
ParticipantPaul,
I am currently considering purchasing this theme for my website. Showing author of the post was actually one of our questions. This feature is very important to us. Is it possible that the feature will be added in a new release of the theme?
Thanks,
IngaNovember 22, 2018 at 3:51 pm #3042Paul
KeymasterHi Inga,
As of now, there are no plans of doing this. You can still use the tweak posted above though.
Kind regards,
PaulNovember 23, 2018 at 1:08 pm #3056ingak
ParticipantPaul,
could please show some screenshots with the use of tweak, particularly: post page with author name, page with all post form particular author (that appears if we click on author name). Moreover, is it possible to show author’s name in posts on the main page?
Best regards,
IngaNovember 29, 2018 at 12:45 pm #3068Paul
KeymasterInga,
The mentioned tweak will add the name of the author styled the same way as the preceding body text.
Judging by the amount of pre-sale requests you have, I would suggest it would be useful for you to shop around and find a theme that suits your specifications out-of-the-box. I mean, with Narrator you will need to apply a certain amount of custom coding to make it what you want, which will take time.
Kind regards,
PaulJune 2, 2019 at 1:42 am #3600Flash1902
ParticipantHi Paul,
Great theme! I was able to set everything up to my liking and really enjoying the clean design and layout.
I do have one question: Is there a way to display the post author between the excerpt and featured image on a post? Could I just take the code you posted above and past it somewhere in functions.php?
I have provided an image below as an example of what I would like to do – thanks!
July 24, 2019 at 8:29 pm #3623Paul
KeymasterHi Flash,
This should do the trick:
if (!function_exists('mauer_prepend_post_author_name')) : function mauer_prepend_post_author_name($html) { if(is_singular() && is_main_query()) { ob_start(); $html = "<p class='mauer-post-author text-left'><i>Post by:" . get_the_author() . "</i></p>" . $html; } return $html; } endif; add_filter('post_thumbnail_html', 'mauer_prepend_post_author_name', 1, 5);
Style the .mauer-post-author class to your liking.
Regards,
Paul-
This reply was modified 1 year, 5 months ago by
Paul.
July 15, 2020 at 10:52 pm #4101juan
ParticipantSorry, I forgot to add this: adapting your theme from an actual customer who purchase the theme at ThemeForest (it’s the theme I suggested he bought, but I’m doing the installation/config). Can provide details via e-mail.
Thanks,
JuanJuly 16, 2020 at 9:38 am #4104juan
ParticipantHello,
I am sorry for the confusion. I wrote a lengthy message followed by the follow-up above, but somehow the first post didn’t get published.
First of all, thank you for creating Narrator. It has a superb design and you can tell you have put tons of work and love into it.
A friend of mine asked me to set up a WP blog for him and I suggested he buy Narrator at ThemeForest. He did and I am now installing it and trying to configure it. I hadn’t noticed the absence of a byline field, so it’s up to me to do it for him.
I have read the author-related posts on this forum, but I’m a newbie with PHP and I’m a bit confused.
Context
I’m using a Narrator child theme created with the most plugin Child Theme Configurator by Lilaea Media. As with every child theme, a small functions.php file is created which only includes the necessary enqueue functions to incorporate custom css styling.
So, I don’t know if I should edit the parent theme functions.php or the child theme functions.php when adding the code you suggested to prepend the author’s byline.
Also, your code seemes to add a filter for both post_thumbnail and the newly created prepend_post_author_name:
add_filter('post_thumbnail_html', 'mauer_prepend_post_author_name', 1, 5);
I have looked at Narrator’s functions.php and I don’t know where to put the snippet exactly. The closest I find is this:
if (!function_exists('mauer_narrator_width_attribute_removal')) : // This does not work for the already existing images. // A CSS solution has been implemented. This code is left here for the old browsers. function mauer_narrator_width_attribute_removal( $html ) { $html = preg_replace( '/(width|height)="\d*"\s/', "", $html ); return $html; } endif; add_filter('post_thumbnail_html', 'mauer_narrator_width_attribute_removal', 100); add_filter('image_send_to_editor', 'mauer_narrator_width_attribute_removal', 100);
And it leaves me very confused, because there is already a line with the add_filter(‘post_thumbnail_html’, string. Do I have to replace or add your code?
Please excuse my ignorance. I’m rather desperate. :_(
Thank you in advance for your time and help.
Very best,
JuanJuly 16, 2020 at 11:24 am #4105juan
ParticipantHello again,
I found a partial solution that works only with the single posts.
I installed the PublishPress Authors plugin, because we needed to include several bylines in some articles. I followed their instructions here:
And I included this line of code in the
single.php
file:<?php do_action('pp_multiple_authors_show_author_box', false, 'inline'); ?>
It now shows both authors in each post, in the typical byline area after the excerpt.
I still don’t know how to make it work in the front page (in the big post and the secondary posts that appear in the 2 col. o 3 col. grid). That is, I don’t know in which other templates/files I should include the
<?php do_action('pp_multiple_authors_show_author_box', false, 'inline'); ?>
code, as I did in thesingle.php
template.Please help. 🙂
Best,
JuanJuly 23, 2020 at 9:34 am #4117juan
ParticipantHi, Pavel
Please advise on how to make the post author show on the front page of Narrator Theme (in the big post and the secondary posts). I cannot do it without your help as the theme creator. You might consider inserting the author a non-supported customisation, but it is a fairly reasonable petition (no design or layout or module-related issues involved).
I’ve tried tweaking these two templates in the child editor theme…
content-big_latest.php
content-grid_2_cols.php
..but the same single-line code that works perfectly with
single.php
(see above) does not render the byline in those two templates.Any help would be greatly appreciated.
пожалуйста, я прошу Вас.
Thank you.
July 27, 2020 at 10:46 pm #4120andergmartins
ParticipantHi Juan,
Just completing your comment, as a reply for: “how to make it work in the front page”.
In addition to add that to the correct template files, for adding the PublishPress Authors output to the front page you have to specify a third argument:<?php do_action(‘pp_multiple_authors_show_author_box’, false, ‘inline’, true); ?>
That “true” in the 3rd argument says you are displaying the output in an archive page (front page, author page, etc).
Btw, that is not required for the single post pages.
July 28, 2020 at 9:01 am #4121juan
ParticipantThank you so much, Anderson. I did try it with the true parameter at the end, but it still won’t show the author in the front page. I will keep trying, though, and I hope that Pavel can join this conversation. 🙂
August 3, 2020 at 2:28 pm #4133Paul
KeymasterHi Juan,
Sorry for the late reply.
You can use the following code to display the author in the archive pages (in single ones as well). This will work without any additional plugins — just native WordPress functionality:
<div class="juan-custom-author-box">Post by: <a href="<?php get_the_author_link(); ?>"><?php the_author(); ?></a></div>
The template files to add it to depend on the layout you use. Basically, they are:
content-big_latest.php
content-grid_2_cols.php
content-grid_3_cols.php
content-masonry.phpThen you can use some CSS to style this block with:
.juan-custom-author-box { }
___
I have tried this plugin you mentioned and from what I can see, it is not adding the names of the authors to the archive pages even in the standard WP theme (I have tried with Twentynineteen). Regardless of whether I use the argument kindly suggested by Ander or not. I have tried using add_action() and also executing the shortcode they offer via do_shortcode().
As this is not working with the standard WP theme, I believe the issue is on the plugin side.
Anyway, I hope the snippet I have suggested works out for you.
Regards,
PaulAugust 3, 2020 at 5:01 pm #4139juan
ParticipantHello, Pavel
Thank you for responding to my support ticket and for trying the plugin in a standard theme. I just tried the standard WP php line you suggested and it works.
I still am clueless as to how to add multiple authors to Narrator. It makes sense for a magazine-style theme. If you do find a solution, would you kindly let me know?
I wonder if updating the theme to let the user show or hide the author(s) on the editing panel is something that you would consider. I am sure many Narrator users would welcome the choice. The fact that it contains an ACF license would make it easy for you (I’m guessing here) to replace the standard WP author combo with a specific field for the authors of a post (with 2 to 4 field instances, for example).
Best,
JuanAugust 3, 2020 at 5:07 pm #4140juan
ParticipantADDENDA. Theres is one thing that doesn’t seem to work after inserting your suggested code in content-big_latest.php,
content-grid_2_cols.php and single.php.—On the front page, clicking on the author’s name doesn’t take you to the listing of that author’s posts. It is linked to the website’s root /.
-On a single post, clicking on the author’s name reloads the page. It is linked to the same post displayed on the page.
Kindly tell me if I’m doing something wrong. All previous plugin code was replaced by the line you suggested, and the plugin is deactivated.
Thank you for your help.
August 3, 2020 at 7:32 pm #4143Paul
KeymasterSorry, my bad. Please use this:
<div class="juan-custom-author-box">Post by: <a href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?>"><?php the_author(); ?></a></div>
This should display all the posts by a certain author. There is not a template for an author in this theme per se.
Regards,
PaulAugust 4, 2020 at 9:37 am #4147juan
ParticipantThank you, Pavel. That worked just fine.
Best
JuanDecember 12, 2020 at 2:49 pm #4236Paul
KeymasterYou are very welcome, Juan!
-
This reply was modified 1 year, 5 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.