' . do_shortcode( get_theme_mod( 'blog_header' ) ) . '';
}
}
add_action( 'flatsome_after_header', 'flatsome_custom_blog_header', 10 );
// Add transparent headers
function flatsome_blog_header_classes( $classes ) {
// Add transparent header to product page if set.
if ( is_singular( 'post' ) && get_theme_mod( 'blog_single_transparent', 0 ) ) {
$classes[] = 'transparent has-transparent nav-dark toggle-nav-dark';
}
if ( get_theme_mod( 'blog_archive_transparent', 0 ) && is_home() ) {
$classes[] = 'transparent has-transparent nav-dark toggle-nav-dark';
}
return $classes;
}
add_filter( 'flatsome_header_class', 'flatsome_blog_header_classes', 10 );
// Add Big blog header
function flatsome_single_page_header(){
if(is_singular('post') && get_theme_mod('blog_post_style') == 'top'){
get_template_part( 'template-parts/posts/partials/single-featured', get_theme_mod('blog_post_style'));
}
}
add_action('flatsome_after_header','flatsome_single_page_header', 10);
// Add Blog Archive title
function flatsome_archive_title() {
if ( get_theme_mod( 'blog_archive_title', 1 ) && ( is_archive() || is_search() ) ) {
get_template_part( 'template-parts/posts/partials/archive-title' );
}
}
add_action( 'flatsome_before_blog', 'flatsome_archive_title', 15 );
// Remove the Auto scrolling if a Read more link is clicked
function flatsome_remove_more_link_scroll( $link ) {
$link = preg_replace( '|#more-[0-9]+|', '', $link );
return $link;
}
add_filter( 'the_content_more_link', 'flatsome_remove_more_link_scroll' );
// Add HTML after blog posts
function flatsome_before_blog_comments(){
if(get_theme_mod('blog_after_post')){
echo '
';
}
}
add_action('flatsome_before_comments','flatsome_before_blog_comments');
// Add button class to read more link
if( ! function_exists('flatsome_add_morelink_class') ) {
function flatsome_add_morelink_class( $link, $text ) {
return str_replace(
'more-link'
,'more-link button primary smaller is-outline'
,$link
);
}
}
add_action( 'the_content_more_link', 'flatsome_add_morelink_class', 10, 2 );
/**
* Display navigation to next/previous pages when applicable
*/
if ( ! function_exists( 'flatsome_content_nav' ) ) :
function flatsome_content_nav( $nav_id ) {
global $wp_query, $post;
// Don't print empty markup on single pages if there's nowhere to navigate.
if ( is_single() ) {
$previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true );
$next = get_adjacent_post( false, '', false );
if ( ! $next && ! $previous )
return;
}
// Don't print empty markup in archives if there's only one page.
if ( $wp_query->max_num_pages < 2 && ( is_home() || is_archive() || is_search() ) )
return;
$nav_class = ( is_single() ) ? 'navigation-post' : 'navigation-paging';
?>
comment_type ) :
case 'pingback' :
case 'trackback' :
?>
', '' ); ?>
id="li-comment-">
%2$s';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '';
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
$posted_on = sprintf(
esc_html_x( 'Posted on %s', 'post date', 'flatsome' ),
'' . $time_string . ''
);
$byline = sprintf(
esc_html_x( 'by %s', 'post author', 'flatsome' ),
'' . esc_html( get_the_author() ) . ''
);
echo '' . $posted_on . ' ' . $byline . '';
}
endif;
function flatsome_featured_sticky_posts( $query ) {
if ( get_theme_mod( 'blog_featured', '' ) && $query->is_home() && $query->is_main_query() ) {
$query->set( 'ignore_sticky_posts', 1 );
if ( get_theme_mod( 'blog_hide_sticky', 0 ) ) $query->set( 'post__not_in', get_option( 'sticky_posts' ) );
}
}
add_action( 'pre_get_posts', 'flatsome_featured_sticky_posts' );
// Filter in a link to a content ID attribute for the next/previous image links on image attachment pages
function flatsome_enhanced_image_navigation( $url, $id ) {
if ( ! is_attachment() && ! wp_attachment_is_image( $id ) )
return $url;
$image = get_post( $id );
if ( ! empty( $image->post_parent ) && $image->post_parent != $id )
$url .= '#main';
return $url;
}
add_filter( 'attachment_link', 'flatsome_enhanced_image_navigation', 10, 2 );
// Numbered Pagination
if ( !function_exists( 'flatsome_posts_pagination' ) ) {
function flatsome_posts_pagination() {
$prev_arrow = is_rtl() ? get_flatsome_icon('icon-angle-right') : get_flatsome_icon('icon-angle-left');
$next_arrow = is_rtl() ? get_flatsome_icon('icon-angle-left') : get_flatsome_icon('icon-angle-right');
global $wp_query;
$total = $wp_query->max_num_pages;
$big = 999999999; // need an unlikely integer
if( $total > 1 ) {
if( !$current_page = get_query_var('paged') )
$current_page = 1;
if( get_option('permalink_structure') ) {
$format = 'page/%#%/';
} else {
$format = '&paged=%#%';
}
$pages = paginate_links(array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => $format,
'current' => max( 1, get_query_var('paged') ),
'total' => $total,
'mid_size' => 3,
'type' => 'array',
'prev_text' => $prev_arrow,
'next_text' => $next_arrow,
) );
if( is_array( $pages ) ) {
$paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged');
echo '';
}
}
}
}