Wordpress single.php layout - php

I am putting together my graphic design/portfolio blog using Wordpress theme 'Salient', I am having a problem with a setting within the theme which controls the layout of a blog post page (single.php), I have little experience with php and am hoping someone could tell me of a simple solution or rework my single.php file to display the way I want it.
I want my blog post page to look like this:
http://www.ravagedesign.com/freebies/greylime-hd-launcher-theme-icon-pack-released/
The blog-title/date/category & social icons are listed below the large feature graphic, I have achieved this by using a slider plugin however this isnt an option long term as I would end up with a huge list on my plugin and this also has a significantly slower page load time.
I dont want it to look like this:
http://www.ravagedesign.com/freebies/greyice-hd-launcher-theme-icon-pack-released/
The blog-title/date/category & social icons are placed inside the feature graphic, this post was made using more conventional methods built into the theme which incorporate the large feature graphic into each individual post.
Is there a modification I can make to my single.php file to use the feature graphic within the post options while placing all info below the feature graphic like the first page.
my single.php file (salient theme):
<?php get_header(); ?>
<?php
global $nectar_theme_skin, $options;
$bg = get_post_meta($post->ID, '_nectar_header_bg', true);
$bg_color = get_post_meta($post->ID, '_nectar_header_bg_color', true);
$fullscreen_header = (!empty($options['blog_header_type']) && $options['blog_header_type'] == 'fullscreen' && is_singular('post')) ? true : false;
$fullscreen_class = ($fullscreen_header == true) ? "fullscreen-header full-width-content" : null;
$theme_skin = (!empty($options['theme-skin']) && $options['theme-skin'] == 'ascend') ? 'ascend' : 'default';
$hide_sidebar = (!empty($options['blog_hide_sidebar'])) ? $options['blog_hide_sidebar'] : '0';
$blog_type = $options['blog_type'];
if(have_posts()) : while(have_posts()) : the_post();
nectar_page_header($post->ID);
endwhile; endif;
if($fullscreen_header == true) {
if(empty($bg) && empty($bg_color)) { ?>
<div class="not-loaded default-blog-title fullscreen-header" id="page-header-bg" data-alignment="center" data-parallax="0" data-height="450" style="height: 450px;">
<div class="container">
<div class="row">
<div class="col span_6 section-title blog-title">
<h1 class="entry-title"><?php the_title(); ?></h1>
<div class="author-section">
<span class="meta-author vcard author">
<?php if (function_exists('get_avatar')) { echo get_avatar( get_the_author_meta('email'), 100 ); }?>
</span>
<div class="avatar-post-info">
<span class="fn"><?php the_author_posts_link(); ?></span>
<span class="meta-date date updated"><i><?php echo get_the_date(); ?></i></span>
</div>
</div>
</div>
</div>
</div>
<i class="icon-salient-down-arrow icon-default-style"> </i>
</div>
<?php }
if($theme_skin != 'ascend') { ?>
<div class="container">
<div id="single-below-header" class="<?php echo $fullscreen_class; ?> custom-skip">
<span class="meta-share-count"><i class="icon-default-style steadysets-icon-share"></i> <?php echo '<span class="share-count-total">0</span> <span class="plural">'. __('Shares',NECTAR_THEME_NAME) . '</span> <span class="singular">'. __('Share',NECTAR_THEME_NAME) .'</span>'; nectar_blog_social_sharing(); ?> </span>
<span class="meta-category"><i class="icon-default-style steadysets-icon-book2"></i> <?php the_category(', '); ?></span>
<span class="meta-comment-count"><i class="icon-default-style steadysets-icon-chat-3"></i> <?php comments_number( __('No Comments', NECTAR_THEME_NAME), __('One Comment ', NECTAR_THEME_NAME), __('% Comments', NECTAR_THEME_NAME) ); ?></span>
</div><!--/single-below-header-->
</div>
<?php }
} ?>
<div class="container-wrap <?php echo ($fullscreen_header == true) ? 'fullscreen-blog-header': null; ?> <?php if($blog_type == 'std-blog-fullwidth' || $hide_sidebar == '1') echo 'no-sidebar'; ?>">
<div class="container main-content">
<?php if(get_post_format() != 'quote' && get_post_format() != 'status' && get_post_format() != 'aside') { ?>
<?php if(have_posts()) : while(have_posts()) : the_post();
if((empty($bg) && empty($bg_color)) && $fullscreen_header != true) { ?>
<div class="row heading-title">
<div class="col span_12 section-title blog-title">
<h1 class="entry-title"><?php the_title(); ?></h1>
<div id="single-below-header">
<span class="meta-author vcard author"><span class="fn"><?php echo __('By', NECTAR_THEME_NAME); ?> <?php the_author_posts_link(); ?></span></span>
<?php if( !empty($options['blog_social']) && $options['blog_social'] == 1) { ?>
<span class="meta-date date updated"><?php echo get_the_date(); ?></span>
<?php } ?>
<span class="meta-category"><?php the_category(', '); ?></span>
<span class="meta-comment-count"><?php comments_number( __('No Comments', NECTAR_THEME_NAME), __('One Comment ', NECTAR_THEME_NAME), __('% Comments', NECTAR_THEME_NAME) ); ?></span>
</ul><!--project-additional-->
</div><!--/single-below-header-->
<div id="single-meta" data-sharing="<?php echo ( !empty($options['blog_social']) && $options['blog_social'] == 1 ) ? '1' : '0'; ?>">
<ul>
<?php if( empty($options['blog_social']) || $options['blog_social'] == 0 ) { ?>
<li>
<?php echo '<span class="n-shortcode">'.nectar_love('return').'</span>'; ?>
</li>
<li>
<?php echo get_the_date(); ?>
</li>
<?php } ?>
</ul>
<?php nectar_blog_social_sharing(); ?>
</div><!--/single-meta-->
</div><!--/section-title-->
</div><!--/row-->
<?php }
endwhile; endif; ?>
<?php } ?>
<div class="row">
<?php $options = get_option('salient');
global $options;
if($blog_type == 'std-blog-fullwidth' || $hide_sidebar == '1'){
echo '<div id="post-area" class="col span_12 col_last">';
} else {
echo '<div id="post-area" class="col span_9">';
}
if(have_posts()) : while(have_posts()) : the_post();
if ( floatval(get_bloginfo('version')) < "3.6" ) {
//old post formats before they got built into the core
get_template_part( 'includes/post-templates-pre-3-6/entry', get_post_format() );
} else {
//WP 3.6+ post formats
get_template_part( 'includes/post-templates/entry', get_post_format() );
}
endwhile; endif;
wp_link_pages();
$options = get_option('salient');
if($theme_skin != 'ascend') {
if( !empty($options['author_bio']) && $options['author_bio'] == true){
$grav_size = 80;
$fw_class = null;
?>
<div id="author-bio" class="<?php echo $fw_class; ?>">
<div class="span_12">
<?php if (function_exists('get_avatar')) { echo get_avatar( get_the_author_meta('email'), $grav_size ); }?>
<div id="author-info">
<h3><span><?php if(!empty($options['theme-skin']) && $options['theme-skin'] == 'ascend') { _e('Author', NECTAR_THEME_NAME); } else { _e('About', NECTAR_THEME_NAME); } ?></span> <?php the_author(); ?></h3>
<p><?php the_author_meta('description'); ?></p>
</div>
<?php if(!empty($options['theme-skin']) && $options['theme-skin'] == 'ascend'){ echo ' '. __("More posts by",NECTAR_THEME_NAME) . ' ' .get_the_author().' '; } ?>
<div class="clear"></div>
</div>
</div>
<?php } ?>
<div class="comments-section">
<?php comments_template(); ?>
</div>
<?php } ?>
</div><!--/span_9-->
<?php if($blog_type != 'std-blog-fullwidth' && $hide_sidebar != '1') { ?>
<div id="sidebar" class="col span_3 col_last">
<?php get_sidebar(); ?>
</div><!--/sidebar-->
<?php } ?>
</div><!--/row-->
<!--ascend only author/comment positioning-->
<div class="row">
<?php if($theme_skin == 'ascend' && $fullscreen_header == true) { ?>
<div id="single-below-header" class="<?php echo $fullscreen_class; ?> custom-skip">
<span class="meta-share-count"><i class="icon-default-style steadysets-icon-share"></i> <?php echo '<span class="share-count-total">0</span> <span class="plural">'. __('Shares',NECTAR_THEME_NAME) . '</span> <span class="singular">'. __('Share',NECTAR_THEME_NAME) .'</span> '; nectar_blog_social_sharing(); ?> </span>
<span class="meta-category"><i class="icon-default-style steadysets-icon-book2"></i> <?php the_category(', '); ?></span>
<span class="meta-comment-count"><i class="icon-default-style steadysets-icon-chat-3"></i> <a class="comments-link" href="<?php comments_link(); ?>"><?php comments_number( __('No Comments', NECTAR_THEME_NAME), __('One Comment ', NECTAR_THEME_NAME), __('% Comments', NECTAR_THEME_NAME) ); ?></a></span>
</div><!--/single-below-header-->
<?php }
if($theme_skin == 'ascend') nectar_next_post_display(); ?>
<?php if( !empty($options['author_bio']) && $options['author_bio'] == true && $theme_skin == 'ascend'){
$grav_size = 80;
$fw_class = 'full-width-section ';
$next_post = get_previous_post();
$next_post_button = (!empty($options['blog_next_post_link']) && $options['blog_next_post_link'] == '1') ? 'on' : 'off';
?>
<div id="author-bio" class="<?php echo $fw_class; if(empty($next_post) || $next_post_button == 'off' || $fullscreen_header == false && $next_post_button == 'off') echo 'no-pagination'; ?>">
<div class="span_12">
<?php if (function_exists('get_avatar')) { echo get_avatar( get_the_author_meta('email'), $grav_size ); }?>
<div id="author-info">
<h3><span><?php if(!empty($options['theme-skin']) && $options['theme-skin'] == 'ascend') { echo '<i>' . __('Author', NECTAR_THEME_NAME) . '</i>'; } else { _e('About', NECTAR_THEME_NAME); } ?></span> <?php the_author(); ?></h3>
<p><?php the_author_meta('description'); ?></p>
</div>
<?php if(!empty($options['theme-skin']) && $options['theme-skin'] == 'ascend'){ echo '' . __("More posts by",NECTAR_THEME_NAME) . ' ' . get_the_author().' '; } ?>
<div class="clear"></div>
</div>
</div>
<?php } ?>
<?php if($theme_skin == 'ascend') { ?>
<div class="comments-section">
<?php comments_template(); ?>
</div>
<?php } ?>
</div>
<?php if($theme_skin != 'ascend') nectar_next_post_display(); ?>
</div><!--/container-->
</div><!--/container-wrap-->
<?php get_footer(); ?>
Any help is greatly appreciated.

you can use plugin : https://wordpress.org/plugins/custom-post-template/
and now u have to copy the single.php and make another template suppose u named it blog.php then add this to top of ur file:
<?php
/** blog.php
*
* The Template for displaying all Blog posts.
*
* Template Name Posts: Blog Page
*/
get_header(); ?>
now copy your content-single.php and named it content-blog.php
and make all the changes in layout here in these two custom files.
make sure that when u change the template then u have to call the content-blog in place of content single in ur blog.php file template.
ex:
while ( have_posts() ) {
the_post();
get_template_part( '/partials/content', 'blog' );
comments_template();
} ?>

Related

How to add new categories in Wordpress search.php

I'm struggling to add new categories in search.php. But I failed. Actually the php file is beyond me. I need help :( I have 4 categories, location, sub-location, city and municipality. But these search codes use only titles. How can I add these categories in search.php file? Anybody can say the resolve please?
if( isset( $_GET['post_type'] ) && $_GET['post_type'] == 'noo_property' ) :
?>
<?php
global $wp_query;
$show_map = noo_get_option('noo_property_listing_map',1);
$show_search = noo_get_option('noo_property_listing_search',1);
$disable_map = ( ! $show_map && $show_search ) ? ' disable_map="true"' : '';
$disable_search_form = ( $show_map && ! $show_search ) ? ' disable_search_form="true"' : '';
$search_layout = noo_get_option('noo_property_listing_map_layout','horizontal');
$advanced_search = ($show_search && noo_get_option('noo_property_listing_advanced_search',0)) ? ' advanced_search="true"' : '';
$title = __('Properties matching your search', 'noo');
?>
<?php get_header();
?>
<div class="container-wrap">
<?php if(!empty($show_map) || !empty($show_search)):?>
<?php echo do_shortcode('[noo_advanced_search_property style="'.$search_layout.'"' . $disable_map . $disable_search_form . $advanced_search . ']');?>
<?php endif;?>
<div class="main-content container-boxed max offset">
<div class="row">
<div class="<?php noo_main_class(); ?>" role="main">
<?php if ( have_posts() ) : ?>
<?php
$args = array(
'query' => $wp_query,
'title' => $title,
'display_mode' => true,
'default_mode' => '',
'show_pagination' => true,
'ajax_pagination' => false,
'show_orderby' => noo_get_option('noo_property_listing_orderby', 1)
);
re_property_loop( $args ); ?>
<?php else : ?>
<?php noo_get_layout( 'no-content' ); ?>
<?php endif; ?>
<?php
wp_reset_query();
wp_reset_postdata();
?>
</div> <!-- /.main -->
<?php get_sidebar(); ?>
</div><!--/.row-->
</div><!--/.container-boxed-->
</div><!--/.container-wrap-->
<?php get_footer(); ?>
<?php else :
?>
<?php get_header(); ?>
<div class="container-wrap">
<div class="main-content container-boxed max offset">
<div class="row">
<div class="<?php noo_main_class(); ?> <?php noo_page_class(); ?>" role="main">
<h1><?php _e('Results For', 'noo'); ?><span>"<?php the_search_query(); ?>"</span></h1>
<div id="search-results">
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<?php if( get_post_type($post->ID) == 'post' ){ ?>
<article class="result">
<div class="content-featured">
<?php noo_featured_content( $post->ID ); ?>
</div>
<h2 class="title"><?php the_title(); ?> <small><?php echo __('Blog Post', 'noo'); ?></small></h2>
<?php if(get_the_excerpt()) the_excerpt(); ?>
<hr/>
</article><!--/search-result-->
<?php }
else if( get_post_type($post->ID) == 'page' ){ ?>
<article class="result">
<h2 class="title"><?php the_title(); ?> <small><?php echo __('Page', 'noo'); ?></small></h2>
<?php if(get_the_excerpt()) the_excerpt(); ?>
<hr/>
</article><!--/search-result-->
<?php }
else if( get_post_type($post->ID) == 'product' ){ ?>
<article class="result">
<?php if(has_post_thumbnail( $post->ID )) {
echo ''. get_the_post_thumbnail($post->ID, 'full', array('title' => '')).'';
} ?>
<h2 class="title"><?php the_title(); ?> <small><?php echo __('Product', 'noo'); ?></small></h2>
<?php if(get_the_excerpt()) the_excerpt(); ?>
<hr/>
</article><!--/search-result-->
<?php } else if( get_post_type($post->ID) == 'noo_property' ){ ?>
<article class="result">
<?php if(has_post_thumbnail( $post->ID )) {
echo ''. get_the_post_thumbnail($post->ID, 'property-image', array('title' => '')).'';
} ?>
<h2 class="title"><?php the_title(); ?> <small><?php echo __('Property', 'noo'); ?></small></h2>
<?php if(get_the_excerpt()) the_excerpt(); ?>
<hr/>
</article><!--/search-result-->
<?php } else { ?>
<article class="result">
<?php if(has_post_thumbnail( $post->ID )) {
echo ''.get_the_post_thumbnail($post->ID, 'full', array('title' => '')).'';
} ?>
<h2 class="title"><?php the_title(); ?></h2>
<?php if(get_the_excerpt()) the_excerpt(); ?>
<hr/>
</article><!--/search-result-->
<?php } ?>
<?php endwhile;
else: echo "<p>" . __('No results found', 'noo') . "</p>"; endif;?>
</div><!--/search-results-->
<?php noo_pagination(); ?>
</div> <!-- /.main -->
<?php get_sidebar(); ?>
</div><!--/.row-->
</div><!--/.container-boxed-->
</div><!--/.container-wrap-->
<?php get_footer(); ?>
<?php endif; ?>
Am I looking wrong php file? Or true

Both PHP statements are executing

I'm working with the ACF plugin in WordPress. For some reason the else statement is executing even when the first statement is true. Why?
<section id="ParksContainer" class="col-lg-6 col-md-6 col-xs-12">
<h1 id="AdventurePostTitle" class="">Parks</h1>
<?php if( have_rows('adventure_location') ):
while( have_rows('adventure_location') ): the_row(); ?>
<ul id="LocationUl">
<li><b>NATIONAL PARK:</b>
<?php if( the_sub_field('national_park') ):?>
<?php echo '<span class="LocationNameSpan">'; the_sub_field('national_park'); echo '</span>'; ?>
<?php else: ?>
<?php echo '<span class="LocationNameSpan">N/A</span>'; ?>
<?php endif; ?>
</li>
<li>
<b>STATE PARK:</b>
<?php if( the_sub_field('state_park') ) {
echo '<span class="LocationNameSpan">'; the_sub_field('state_park'); echo '</span>';
} else {
echo '<span class="LocationNameSpan">N/A</span>';
}
?>
</li>
</ul>
<?php endwhile; ?>
<?php endif; ?>
</section><!--Parks Container-->
Any suggestions?

Wordpress The_content() returns null home

i have the content function at the end of this code that must show something under the posts and it shows in the single page (post details page)
but in the home just shows nothing at all
here is my code
<?php
/**
* The template for content.
*
* #package Webdoone
* #subpackage Ruby
* #since Ruby 1.1
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class('wow fadeInUp'); ?>>
<?php if (has_post_format('gallery')) { ?>
<?php $images = get_post_meta($post->ID, '_format_gallery_images', true); ?>
<?php
if ($images) { ?>
<div class="post-img">
<div class="post-type-icon">
<i class="fa fa-picture-o"></i>
</div>
<div class="outter"><div class="inner">
<ul class="bxslider">
<?php
foreach ($images as $image) {
if ((get_theme_mod('ruby_webdoone_home_layout_settings') === 'home-ful' ) || (get_theme_mod('ruby_webdoone_archive_layout_settings') === 'arch-ful' ) || (get_theme_mod('ruby_webdoone_post_layout_settings') === 'post-ful' )) {
$the_image = wp_get_attachment_image_src($image, 'ruby_webdoone_custom_width');
$the_caption = get_post_field('post_excerpt', $image); ?>
<li><img src="<?php echo esc_url($the_image[0]); ?>"
<?php
if ($the_caption) {?>
title="<?php echo esc_attr($the_caption); ?>"<?php
}; ?> /></li><?php
} else {
$the_image = wp_get_attachment_image_src($image, 'ruby_webdoone_full_width');
$the_caption = get_post_field('post_excerpt', $image); ?>
<li><img src="<?php echo esc_url($the_image[0]); ?>"
<?php
if ($the_caption) { ?>
title="<?php echo esc_attr($the_caption); ?>"<?php
}; ?> /></li><?php
};
}; ?>
</ul>
</div></div>
</div><?php
}
} elseif (has_post_format('video')) { ?>
<div class="post-img video">
<div class="post-type-icon">
<i class="fa fa-video-camera"></i>
</div>
<div class="outter"><div class="inner">
<div class="fluid-width-video-wrapper" >
<?php $ruby_video = get_post_meta($post->ID, '_format_video_embed', true); ?>
<?php
echo $ruby_video;
?>
</div></div></div>
</div><?php
} elseif (has_post_format('audio')) { ?>
<div class="post-img audio">
<div class="post-type-icon">
<i class="fa fa-music"></i>
</div>
<?php $ruby_audio = get_post_meta($post->ID, '_format_audio_embed', true); ?>
<?php
if (wp_oembed_get($ruby_audio)) {
echo wp_oembed_get($ruby_audio);
} else {
echo esc_url($ruby_audio);
}; ?>
</div><?php
} else {
if (has_post_thumbnail()) { ?>
<div class="post-img">
<?php if (is_sticky()) { ?>
<div class="post-type-icon">
<i class="fa fa-thumb-tack"></i>
</div>
<?php } else { ?>
<div class="post-type-icon">
<i class="fa fa-pencil"></i>
</div>
<?php }
if (is_home()) {
if (!empty($_GET['layout'])) {
$layout = $_GET['layout'];
} else {
$layout = '';
};
if ((get_theme_mod('ruby_webdoone_home_layout_settings') === 'home-ful') || ($layout === 'home-ful')) { ?>
<div class="outter"><div class="inner">
<div class="grid home-full-thumb"><figure class="effect-jazz"><?php the_post_thumbnail('ruby_webdoone_full_width'); ?><figcaption></figcaption></figure></div> </div></div><?php
} else { ?>
<div class="outter"><div class="inner">
<div class="grid home-post-thumb"><figure class="effect-jazz"><?php the_post_thumbnail('ruby_webdoone_content_width'); ?><figcaption></figcaption></figure></div>
</div></div>
<?php
};
} elseif (is_single()) {
if (!empty($_GET['layout'])) {
$layout = $_GET['layout'];
} else {
$layout = '';
};
if ((get_theme_mod('ruby_webdoone_post_layout_settings') === 'post-ful') || ($layout === 'post-ful')) {
?>
<div class="outter"><div class="inner">
<?php the_post_thumbnail('ruby_webdoone_full_width'); ?>
</div></div>
<?php
} else {
?>
<div class="outter"><div class="inner">
<?php the_post_thumbnail('ruby_webdoone_content_width');?>
</div></div>
<?php
};
} else {
if (!empty($_GET['layout'])) {
$layout = $_GET['layout'];
} else {
$layout = '';
};
if ((get_theme_mod('ruby_webdoone_archive_layout_settings') === 'arch-ful') || ($layout === 'arch-ful')) { ?>
<div class="outter"><div class="inner">
<?php the_post_thumbnail('ruby_webdoone_full_width'); ?>
</div></div>
<?php
} else { ?>
<div class="outter"><div class="inner">
<?php the_post_thumbnail('ruby_webdoone_content_width'); ?>
</div></div>
<?php
};
};?>
</div><?php
};
}; ?>
<div class="post-header">
<?php
if (is_home()) { ?>
<h3><a class="pos-header-title-link" href="<?php esc_url(the_permalink()); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3><?php
} elseif (is_single()) { ?>
<h1 class="pos-header-title-link"><?php the_title(); ?></h1><?php
} else { ?>
<h2><a class="pos-header-title-link" href="<?php esc_url(the_permalink()); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2><?php
} ?>
<div class="post-info">
<span class="author"><?php esc_html_e('Author:', 'ruby') ?> <?php the_author_posts_link(); ?> \ </span>
<span class="date"><?php the_time(get_option('date_format')); ?> \ </span><span class="cat"><?php the_category(', '); ?></span>
<span class="comments-count">\ <?php printf( _nx( '1 Comment', '%1$s Comments', get_comments_number(), 'comments number', 'ruby' ), number_format_i18n( get_comments_number() ) ); ?></span>
</div>
</div>
<div class="post-data" itemprop="articleBody"><?php
the_content();
?> </div>
</article>
<?php wp_reset_postdata();
?>
how can i fix this ?
actually content must show this pictures section under posts and text or etc have no problem when i remove this func , wordpress wont show the like and other buttons under the posts .
please try this according to wp documentation
// Declare global $more (before the loop).
global $more;
// Set (inside the loop) to display all content, including text below more.
$more = 1;
the_content();
the_content does not work outside of "The Loop"
https://wordpress.stackexchange.com/a/44153/54343
edit: something akin to this is "the Loop"
<?php
if (have_posts()) {
while (have_posts()) {
the_post();
the_content();
}
}
?>

add badge to thumbnail image

What I want to do on the front page where I have recent posts, is to add a small upper corner badge or ribbon that says "NEW" to the thumbnails of posts that were published on today's date. Below is my index.php which controls the front page layout:
<?php
/**
* The main template file.
*
* Used to display the homepage when home.php doesn't exist.
*/
?>
<?php
// Get options
$mts_options = get_option(MTS_THEME_NAME);
// Featured Section 1 settings ( slider is here) --------------------------------
$slider_enabled = ( $mts_options['mts_featured_slider'] === '1' ) ? true : false;
if ( empty($mts_options['mts_featured_slider_cat']) || !is_array($mts_options['mts_featured_slider_cat']) ) {
$mts_options['mts_featured_slider_cat'] = array('0');
}
$slider_cat = implode(",", $mts_options['mts_featured_slider_cat']);
// Featured Section settings --------------------------------------------------
$f2_title = $mts_options['mts_featured_section_2_title'];
if ( empty($mts_options['mts_featured_section_2_cat']) || !is_array($mts_options['mts_featured_section_2_cat']) ) {
$mts_options['mts_featured_section_2_cat'] = array('0');
}
$f2_cat= implode(",", $mts_options['mts_featured_section_2_cat']);
// Featured Section 3 settings --------------------------------------------------
get_header(); ?>
<div id="page">
<div class="article">
<?php if ( $slider_enabled && is_home() && !is_paged() ) { ?>
<section id="featured-section-1" class="featured-section featured-section-1-1 clearfix">
<div class="slider-container">
<div class="primary-slider-container clearfix loading">
<div id="slider" class="primary-slider">
<?php
$slider_full = 'best-featuredfull';
if ( empty( $mts_options['mts_custom_slider'] ) ) {
$my_query = new WP_Query('cat='.$slider_cat.'&posts_per_page='.$mts_options['mts_featured_slider_num']);
while ( $my_query->have_posts() ) : $my_query->the_post();
?>
<div>
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail($slider_full,array('title' => '')); ?>
<div class="slider-caption">
<?php if(isset($mts_options['mts_home_headline_meta_info']['enabled']) && $mts_options['mts_home_headline_meta_info']['enabled']){ ?>
<div class="sliderdate">
<?php if(isset($mts_options['mts_home_headline_meta_info']['enabled']['date']) == '1') { ?>
<span class="thetime updated"><?php the_time( get_option( 'date_format' ) ); ?></span>
<?php } ?>
</div>
<?php } ?>
<h2 class="slide-title"><?php the_title(); ?></h2>
</div>
<div class="post-day"><?php if (function_exists('wp_review_show_total')) wp_review_show_total(true, 'review-total-only'); ?></div>
</a>
</div>
<?php endwhile; wp_reset_postdata();
} else { ?>
<?php foreach( $mts_options['mts_custom_slider'] as $slide ) : ?>
<div>
<a href="<?php echo esc_url( $slide['mts_custom_slider_link'] ); ?>">
<?php echo wp_get_attachment_image( $slide['mts_custom_slider_image'], $slider_full, false, array('title' => '') ); ?>
<div class="slider-caption">
<div class="sliderdate"><?php echo esc_html( $slide['mts_custom_slider_title'] ); ?></div>
<h2 class="slide-title"><?php echo esc_html( $slide['mts_custom_slider_text'] ); ?></h2>
</div>
</a>
</div>
<?php endforeach; ?>
<?php } ?>
</div>
</div>
</div><!-- slider-container -->
</section>
<?php } ?>
<?php if( $mts_options['mts_featured_section_2'] === '1' && is_home() && !is_paged() ) {// featured section 2 ?>
<section id="featured-section-3" class="featured-section clearfix">
<?php if (!empty($f2_title)) { ?><h4 class="featured-section-title"><?php echo $f2_title;?></h4><?php } ?>
<?php
$f2_query = new WP_Query('cat='.$f2_cat.'&posts_per_page=4');
$f2_count = 1; if ($f2_query->have_posts()) : while ($f2_query->have_posts()) : $f2_query->the_post();
$f2_loop_params = best_mixed_layout_params( 1, 2, $f2_count );// see functions.php
$f2_clear_class = $f2_loop_params['clear_class'];
$f2_type_class = $f2_loop_params['box_class'];
$f2_loop_thumb = $f2_loop_params['thumb'];
$f2_show_excerpt = $f2_loop_params['show_excerpt'];
$f2_show_author = $f2_loop_params['show_author'];
$begin_f2_extra_wrappers = $f2_loop_params['open_wrappers'];
$end_f2_extra_wrappers = $f2_loop_params['close_wrappers'];
?>
<article class="post-box latestPost mixed <?php echo $f2_type_class;?> <?php echo $f2_clear_class;?>">
<?php echo $begin_f2_extra_wrappers; ?>
<div class="post-img">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="nofollow">
<?php the_post_thumbnail($f2_loop_thumb,array('title' => '')); ?>
</a>
</div>
<div class="post-data">
<div class="post-data-container">
<header>
<h2 class="title post-title"><?php the_title(); ?></h2>
<?php mts_the_postinfo(); ?>
</header>
<?php if ($f2_show_excerpt) : ?>
<div class="post-excerpt">
<?php echo mts_excerpt(40); ?>
</div>
<?php endif; ?>
</div>
</div>
<?php echo $end_f2_extra_wrappers; ?>
</article><!--.post-box-->
<?php $f2_count++; endwhile;
endif; wp_reset_postdata();
?>
</section><!--#featured-section-3-->
<?php } ?>
<div id="content_box">
<?php $latest_posts_used = false;
if ( !empty( $mts_options['mts_featured_categories'] ) ) {
foreach ( $mts_options['mts_featured_categories'] as $section ) {
$category_id = $section['mts_featured_category'];
$featured_category_layout = $section['mts_featured_category_layout'];
$posts_num = $section['mts_featured_category_postsnum'];
if ( $category_id === 'latest' && ! $latest_posts_used ) {
$latest_posts_used = true;
$fc_section_class = ( in_array( $featured_category_layout, array( 'vertical', 'mixed' ) ) ) ? '' : ' '.$featured_category_layout;
?>
<section id="latest-posts" class="clearfix<?php echo $fc_section_class ?><?php //echo $fc_section_no_gap ?>">
<h4 class="featured-section-title"><?php _e( "Latest", "best" ); ?></h4>
<?php $j = 1; if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php best_the_homepage_article( $featured_category_layout, $j, true );?>
<?php $j++; endwhile; endif; ?>
<!--Start Pagination-->
<?php if (isset($mts_options['mts_pagenavigation_type']) && $mts_options['mts_pagenavigation_type'] == '1' ) { ?>
<?php $additional_loop = 0; mts_pagination($additional_loop['max_num_pages']); ?>
<?php } else { ?>
<div class="pagination pagination-previous-next">
<ul>
<li class="nav-previous"><?php next_posts_link( '<i class="fa fa-chevron-left"></i> '. __( 'Previous', 'best' ) ); ?></li>
<li class="nav-next"><?php previous_posts_link( __( 'Next', 'best' ).' <i class="fa fa-chevron-right"></i>' ); ?></li>
</ul>
</div>
<?php } ?>
<!--End Pagination-->
</section><!--#latest-posts-->
<?php } elseif ( $category_id !== 'latest' && !is_paged() ) {
$fc_section_class = ( in_array( $featured_category_layout, array( 'vertical', 'mixed' ) ) ) ? '' : ' '.$featured_category_layout;
?>
<section class="featured-section clearfix<?php echo $fc_section_class ?>">
<h4 class="featured-section-title"><?php echo get_cat_name($category_id); ?></h4>
<?php $cat_query = new WP_Query('cat='.$category_id.'&posts_per_page='.$posts_num); ?>
<?php $j = 1; if ($cat_query->have_posts()) : while ($cat_query->have_posts()) : $cat_query->the_post(); ?>
<?php best_the_homepage_article( $featured_category_layout, $j );?>
<?php $j++; endwhile; endif; wp_reset_postdata();?>
</section>
<?php } ?>
<?php } ?>
<?php } ?>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
What I have is this: to check the date and display the badge (not including css) but not sure where to input it exactly:
<?php
$days_old = (current_time(timestamp) - get_the_time('U') - (get_settings('gmt_offset') *3600 ) ) / (60*60*24);
if ($days_old <=1) {
echo <div class="post-badge">NEW</div>;
}
?>
I want to insert it into The Latest Post Section. Any help would be greatly appreciated:)

Wordpress Parse error: syntax error, unexpected T_STRING

I am getting the following error message when I try to access one of the links on the blog on my Wordpress site:
Parse error: syntax error, unexpected T_STRING in /home/insuranc/public_html/wp-content/themes/inovado/single.php on line 118
<?php get_header(); ?>
<!-- Title Bar -->
<?php if ( $data['select_blogtitlebar'] == 'Image' ) { ?>
<div id="alt-title" class="post-thumbnail" style="background-image: url( <?php echo $data['media_blogtitlebar']; ?> );">
<div class="grid"></div>
<div class="container">
<h1><?php echo $data['text_blogtitle']; ?><?php if($data['text_titledivider'] != "") { echo $data['text_titledivider']; } ?></h1>
<?php if($data['text_blogsubtitle']){ echo '<h2>'.$data['text_blogsubtitle'].'</h2>'; } ?>
</div>
</div>
<?php if($data['check_blogbreadcrumbs'] == 0){ ?>
<div id="alt-breadcrumbs">
<div class="container">
<?php minti_breadcrumbs(); ?>
</div>
</div>
<?php } ?>
<?php if($data['check_stripedborder']) { ?><div class="hr-border"></div><?php } ?>
<?php } elseif ($data['select_blogtitlebar'] == 'No Titlebar') { ?>
<?php if($data['check_blogbreadcrumbs'] == 0){ ?>
<div id="no-title">
<div class="container">
<div id="breadcrumbs" class="sixteen columns <?php if(get_post_meta( get_option('page_for_posts'), 'minti_subtitle', true )){ echo 'breadrcumbpadding'; } /* to align middle */ ?>">
<?php minti_breadcrumbs(); ?>
</div>
</div>
</div>
<?php if($data['check_stripedborder']) { ?><div class="hr-border"></div><?php } ?>
<?php } else { ?>
<div id="no-title-divider"></div>
<?php if($data['check_stripedborder']) { ?><div class="hr-border"></div><?php } ?>
<?php } ?>
<?php } else { ?>
<div id="title">
<div class="container">
<div class="ten columns">
<h1><?php echo $data['text_blogtitle']; ?><?php if($data['text_titledivider'] != "") { echo $data['text_titledivider']; } ?></h1>
<?php if($data['text_blogsubtitle']){ echo '<h2>'.$data['text_blogsubtitle'].'</h2>'; } ?>
</div>
<?php if($data['check_blogbreadcrumbs'] == 0){ ?>
<div id="breadcrumbs" class="six columns <?php if($data['text_blogsubtitle']){ echo 'breadrcumbpadding'; } /* to align middle */ ?>">
<?php minti_breadcrumbs(); ?>
</div>
<?php } ?>
</div>
</div>
<?php if($data['check_stripedborder']) { ?><div class="hr-border"></div><?php } ?>
<?php } ?>
<!-- End: Title Bar -->
<div id="page-wrap" class="container">
<div id="content" class="<?php echo $data['select_blogsidebar']; ?> twelve columns single">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php get_template_part( 'framework/inc/post-format/single', get_post_format() ); ?>
<?php if($data['check_sharebox'] == true) { ?>
<?php get_template_part( 'framework/inc/sharebox' ); ?>
<?php } ?>
<?php if($data['check_authorinfo'] == true) { ?>
<div id="author-info" class="clearfix">
<div class="author-image">
<?php echo get_avatar( get_the_author_meta('user_email'), '35', '' ); ?>
</div>
<div class="author-bio">
<h4><?php _e('About the Author', 'minti'); ?></h4>
<?php the_author_meta('description'); ?>
</div>
</div>
<?php } ?>
<?php if($data['check_relatedposts'] == true) { ?>
<div id="related-posts">
<?php
//for use in the loop, list 5 post titles related to first tag on current post
$tags = wp_get_post_tags($post->ID);
if ($tags) {
?>
<h3 class="title"><span><?php _e('Related Posts', 'minti'); ?></span></h3>
<ul>
<?php $first_tag = $tags[0]->term_id;
$args=array(
'tag__in' => array($first_tag),
'post__not_in' => array($post->ID),
'showposts'=>3
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li><?php the_title(); ?> <span>(<?php the_time(get_option('date_format')); ?>)</span></li>
<?php
endwhile;
wp_reset_query();
}
}
?>
</ul>
</div>
<?php } ?>
<div class="comments"><? php comments_template(); ?></div>
<div class="post-navigation">
<div class="alignleft prev"><?php previous_post_link('%link', 'Prev Post', FALSE); ?></div>
<div class="alignright next"><?php next_post_link('%link', 'Next Post', FALSE); ?> </div>
</div>
<?php endwhile; endif; ?>
</div>
<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>
There is a space between the <? and the php .. Remove it on Line 118
<? php comments_template(); ?></div>.
^----- Remove this.

Categories