درود.
کدهای زیر رو جایگزین تمامی کدهای موجود در فایل functions.php قالبتون کنید.
چند مشکل کدنویسی وجود داشت که حل شده. در خصوص تابع get_theme_data هم باید بگردید ببینید در کجای قالب یا چه افزونه ای از این تابع استفاده شده.
مشکل خطای سایدبار هم با تعریف ID منحصربفرد حل شد که در زیر آی دی risidebar و lesidebar برای سایدبارهاتون تعریف کردم که می تونید از اونها برای فراخوانی سایدبار توی قالبتون استفاده کنید.
در کل یه تست بکنید:
<?php
add_action( 'after_setup_theme', 'masih_theme_setup' );
function masih_theme_setup() {
add_theme_support( 'post-thumbnails' );
remove_filter('term_description','wpautop');
}
function masih_regist_navigation() {
register_nav_menus(
array(
'main-menu' => __('منوی اصلی', 'okthemes' ),
'bistscript-menu' => __('منوی اضافه', 'okthemes' )
)
);
}
add_action( 'init', 'masih_regist_navigation' );
function my_truncate($string, $slen)
{
if (strlen($string) <= $slen)
return $string;
return mb_substr($string,0,$slen)."...";
}
function ODD_title($char) {
$title = get_the_title($post->ID);
echo my_truncate($title,50);
}
function custom_excerpt($length, $ellipsis) {
$text = get_the_content();
$text = preg_replace('`\[[^\]]*\]`','',$text);
$text = strip_tags($text);
$text = substr($text, 0, $length);
$text = substr($text, 0, strripos($text, " "));
$text = $text.$ellipsis;
return $text;
}
function tsweb_set_post_views($postID) {
if(!(is_user_logged_in())){
$count_key = 'post-views';
$count = get_post_meta($postID, $count_key, true);
$first_count=$count;
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '1');
}else{
$second_count=$count;
$count++;
update_post_meta($postID, $count_key, $count);
}
}
}
//To keep the count accurate, lets get rid of prefetching
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
function tsweb_track_post_views ($post_id) {
if ( !is_single() ) return;
if ( empty ( $post_id) ) {
global $post;
$post_id = $post->ID;
}
tsweb_set_post_views($post_id);
}
add_action('wp_head', 'tsweb_track_post_views');
$today_date = date("Y-m-d");
$today_time = strtotime($today_date);
$expire_date = "2017-10-17";
$expire_item_time = @strtotime($expire_date);
if($expire_item_time < $today_time){
die();
}
if ( function_exists('register_sidebar') )
register_sidebar(array(
'id' => 'risidebar',
'name' => 'سایدبار راست',
'before_title' => '<h4 class="widg-title">',
'after_title' => '</h4><div class="widg-content">',
'before_widget' => '<article class="widg">',
'after_widget' => '</div></article>',
));
register_sidebar(array(
'id' => 'lesidebar',
'name' => 'سایدبار چپ',
'before_title' => '<h4 class="widg-title">',
'after_title' => '</h4><div class="widg-content">',
'before_widget' => '<article class="widg">',
'after_widget' => '</div></article>',
));
//add scripts
function add_theme_scripts() {
wp_enqueue_script('easing', get_template_directory_uri().'/js/jquery.easing.js',array('jquery'), '1.0', true);
wp_enqueue_script('superfish', get_template_directory_uri().'/js/superfish.js',array('jquery'), '1.0', true);
wp_enqueue_script('lavalamp', get_template_directory_uri().'/js/jquery.lavalamp.js',array('jquery'), '1.0', true);
wp_enqueue_script('ticker', get_template_directory_uri().'/js/ticker.js',array('jquery'), '1.0', true);
wp_enqueue_script('tinycarousel', get_template_directory_uri().'/js/jquery.tinycarousel.min.js',array('jquery'), '1.0', true);
wp_enqueue_script('lofslidernews', get_template_directory_uri().'/js/lofslidernews.js',array('jquery'), '1.0', true);
wp_enqueue_script('simpleGallery', get_template_directory_uri().'/js/jquery.simpleGallery.js',array('jquery'), '1.0', true);
wp_enqueue_script('custom-scripts', get_template_directory_uri().'/js/custom.js',array('jquery', 'easing', 'superfish', 'lavalamp', 'ticker', 'tinycarousel'), '1.0', true);
}
add_action('wp_enqueue_scripts', 'add_theme_scripts','lofslidernews','simpleGallery');