If anyone would like to know how to show the author of a post on a slide, together with the title, the date, and the contents, I think I figured it out, so here’s how I did it.
First, add an option in the slider settings.
In edit.php, after the code:
<input type="checkbox" class="FA_optional" name="show_date" id="show_date" value="1" checked="checked" disabled="disabled" /> <label for="show_date" class="FA_optional disabled" title="">
add this:
<input type="checkbox" class="FA_optional" name="show_post_author" id="show_post_author" value="1" checked="checked" disabled="disabled" /> <label for="show_post_author" class="FA_optional disabled" title="">
Then in your fa-lite theme folder (I’m modifying classic), modify this function:
function fa_classic_optional_fields( $fields ){ $fields['classic_thumb_animate'] = 0; // 0 is disabled, 1 is enabled return $fields; }
by adding this line:
function fa_classic_optional_fields( $fields ){ $fields['classic_thumb_animate'] = 0; // 0 is disabled, 1 is enabled $fields['show_post_author'] = 1; return $fields; }
Then in common.php, in the function ‘FA_slider_options’, in the ‘_fa_lite_aspect’ array, add “‘show_post_author’ => true” like this:
'_fa_lite_aspect'=>array( 'section_display' =>1, // display title of slider 'section_title' =>'Featured articles', // default slider title 'slider_width' =>'100%', // slider width 'slider_height' =>300, // slider height 'thumbnail_display' =>true, // display article image 'th_size' =>'thumbnail', // article image size 'thumbnail_click' =>false, // article image is clickable 'title_click' =>false, // title is clickable 'title_custom' =>false, // custom defined title usage 'use_excerpt' =>false, // excerpt usage 'use_custom_text' =>false, // use custom text set on posts/pages 'strip_shortcodes' =>true, // remove shortcodes from post/page/custom slide content 'desc_truncate' =>500, // truncate descriptions with image 'desc_truncate_noimg' =>800, // truncate descriptions without image 'end_truncate' =>'...', // end truncated text with this 'read_more' =>'Read more', // read more link text 'allowed_tags' =>'<a>', // allowed tags in truncated descriptions 'allow_all_tags' =>false, // allow all HTML tags 'bottom_nav' =>true, // display bottom navigation 'sideways_nav' =>true, // display sideways navigation 'show_title' =>true, // show or hide titles 'show_text' =>true, 'show_read_more' =>true, 'show_date' =>true, 'show_post_author' =>true ),
Then add a function in common.php:
/** * Outputs the post author * * @param string $before - html to put before text * @param string $after - html to put after text * @param bool $echo - echo (true) or return(false) the html * @return string - formatted date */ function the_fa_author( $before = '', $after = '', $echo = true ){ global $post, $FA_slider_options; if( !$post || !$FA_slider_options['_fa_lite_aspect']['show_post_author'] ) return; $author_id=$post->post_author; $curuser = get_userdata($author_id); $the_author = $curuser->display_name; // or $curuser->nicename if( $echo ){ echo $before.$the_author.$after; }else{ return $before.$the_author.$after; } }
And finally adjust the fa-lite theme display.php accordingly, wherever you want the author’s name to show, with a line like this:
the_fa_author('by <span class="FA_post_author">','</span>');
You can also add some css styling to the fa-lite theme stylesheet.css, using the class ‘FA_post_author’, perhaps like this:
.FA_overall_container_classic .FA_featured_articles .FA_article span.FA_post_author{ font-size:14px; font-weight: bold; color:#DDDBA9; }
If there is any better way of doing this please let me know. Especially considering that it will all get overwritten with any kind of plugin update…
Be First to Comment