رفتن به مطلب

تغییر کد فاکشن و مشکل عدم ورود به ادمین


پست های پیشنهاد شده

با سلام

من تا چندی پیش برای استفاده از تصویر شاخص از کد زیر در فانکشن:

<?php
if (function_exists('add_theme_support')) {
add_theme_support( 'post-thumbnails' );
}
# Displays post image attachment (sizes: thumbnail, medium, full)
function dp_attachment_image($postid=0, $size='thumbnail', $attributes='') {
if ($postid<1) $postid = get_the_ID();
if ($images = get_children(array(
'post_parent' => $postid,
'post_type' => 'attachment',
'numberposts' => 1,
'post_mime_type' => 'image',)))
foreach($images as $image) {
$attachment=wp_get_attachment_image_src($image->ID, $size);
?><img src="<?php echo $attachment[0]; ?>" <?php echo $attributes; ?> /><?php
}
}
?>

و از کد های زیر در پوسته استفاده میکردم:

<?php dp_attachment_image($post->ID, 'medium', 'alt="' . $post->post_title . '"'); ?>

ولی این کدها تصویر شاخص رو قرار نمیداد و فقط آخرین تصویر ارسال شده رو نشون می داد

بعدا متوجه شده که وردپرس 2.9 به بالا خودش تصویر شاخص رو پشتیبانی می کنه و فقط باید از کدهایی مثل:

<?php the_post_thumbnail('thumbnail'); ?>

استفاده کرد.

حالا که کدا بالا رو از فانکشن برداشتم مشکل صفحه سفید برای ادمین پیدا کردم.

البته سایت رو درست نمایش میده. همنطور تصویر شاخص رو

چه باید بکنم؟

ضمنا کل فانکشن من اینه:

<?php function mEhdi_remove_version() {
return '';
}

add_filter('the_generator', 'mEhdi_remove_version');
?>
<?php
function getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return "بدون بازدید";
}
return $count.' بار این مطلب بازدید شده است ';
}
// function to count views.
function setPostViews($postID) {
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}
?>
<?php function the_breadcrumb() {
if (!is_home()) {
echo '<a href="';
echo get_option('home');
echo '">';
bloginfo('name');
echo "</a> « ";
if (is_category() || is_single()) {
the_category('title_li=');
if (is_single()) {
echo " « ";
the_title();
}
} elseif (is_page()) {
echo the_title();
}
}
}
?>
<?php register_nav_menus(
array(
'nav-1' => __( 'nav 1' )
)
);
?>
<?php
add_action('init', 'remheadlink');
function remheadlink() {
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
}
?>
<?php
function logged_in( $expirein ) {
return 1200;
}
add_filter( 'auth_cookie_expiration', 'logged_in' );
?>
<?php function popularPosts($num) {
global $wpdb;
$posts = $wpdb->get_results("SELECT comment_count, ID, post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , $num");
foreach ($posts as $post) {
setup_postdata($post);
$id = $post->ID;
$title = $post->post_title;
$count = $post->comment_count;
if ($count != 0) {
$popular .= '<li>';
$popular .= '<a href="' . get_permalink($id) . '" title="' . $title . '">' . $title . '</a> ';
$popular .= '</li>';
}
}
return $popular;
}
?>
<?php add_shortcode( 'member', 'member_check_shortcode' );
function member_check_shortcode( $atts, $content = null ) {
if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )
return $content;
return '';
} ?>

لینک به ارسال

سلام

در برخورد با فانکشن خیلی باید احتیاط کرد.ازش بک آپ ندارین برگردونین؟؟

چک کنین که این زیری دقیقا آخرین خط باشه و بعد از اون هیچ خطی وجود نداشته باشه


?>

لینک به ارسال

<?php

function mEhdi_remove_version() {

return '';

}

add_filter('the_generator', 'mEhdi_remove_version');

function getPostViews($postID){

$count_key = 'post_views_count';

$count = get_post_meta($postID, $count_key, true);

if($count==''){

delete_post_meta($postID, $count_key);

add_post_meta($postID, $count_key, '0');

return "بدون بازدید";

}

return $count.' بار این مطلب بازدید شده است ';

}

// function to count views.

function setPostViews($postID) {

$count_key = 'post_views_count';

$count = get_post_meta($postID, $count_key, true);

if($count==''){

$count = 0;

delete_post_meta($postID, $count_key);

add_post_meta($postID, $count_key, '0');

}else{

$count++;

update_post_meta($postID, $count_key, $count);

}

}

function the_breadcrumb() {

if (!is_home()) {

echo '<a href="';

echo get_option('home');

echo '">';

bloginfo('name');

echo "</a> « ";

if (is_category() || is_single()) {

the_category('title_li=');

if (is_single()) {

echo " « ";

the_title();

}

} elseif (is_page()) {

echo the_title();

}

}

}

register_nav_menus(

array(

'nav-1' => __( 'nav 1' )

)

);

add_action('init', 'remheadlink');

function remheadlink() {

remove_action('wp_head', 'rsd_link');

remove_action('wp_head', 'wlwmanifest_link');

}

function logged_in( $expirein ) {

return 1200;

}

add_filter( 'auth_cookie_expiration', 'logged_in' );

function popularPosts($num) {

global $wpdb;

$posts = $wpdb->get_results("SELECT comment_count, ID, post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , $num");

foreach ($posts as $post) {

setup_postdata($post);

$id = $post->ID;

$title = $post->post_title;

$count = $post->comment_count;

if ($count != 0) {

$popular .= '<li>';

$popular .= '<a href="' . get_permalink($id) . '" title="' . $title . '">' . $title . '</a> ';

$popular .= '</li>';

}

}

return $popular;

}

add_shortcode( 'member', 'member_check_shortcode' );

function member_check_shortcode( $atts, $content = null ) {

if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )

return $content;

return '';

}

if (function_exists('add_theme_support')) {

add_theme_support( 'post-thumbnails' );

}

?>

تست کنید

لینک به ارسال

با یک سیستم دیگه چک کنید و یا به وسیله نرم افزاری مثل CCleaner ریجستری ویندوزتون رو مرتب کنید و مجدد چک کنید و خبر بدید

لینک به ارسال

کد را به شرایط قبل برگردونید و تست بگیرید

به نظر من بعیده ایراد از این قسمت باشه چون بخشی که شما دست کاری کردید می تونست باعث بالا نیومدن سایت بشه ولی مشکل در ادمین خیر

آدرس آنلاین رو هم بگذارید پینگ کلی سایتتون هم بررسی بشه

لینک به ارسال

بله برای من هم خیلی عجیبه

آدرس سایت اینه: http://farhangi.sepnu.ac.ir/

کدها رو به شرایط قبل بازگردندم ولی باز هم مین مشکل رو داره

لینک به ارسال

آقا از کمک ها و راهنمایی هاتون ممنون

درست شد.

فایل رو پاک کردم.

از توی پنل فایل رو پاک کردم و همونجا کدها رو یکی یکی اضافه و امتحان کردم.

تشکر از محبتاتون

طاعات قبول :)

لینک به ارسال

به گفتگو بپیوندید

هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .

مهمان
ارسال پاسخ به این موضوع ...

×   شما در حال چسباندن محتوایی با قالب بندی هستید.   حذف قالب بندی

  تنها استفاده از 75 اموجی مجاز می باشد.

×   لینک شما به صورت اتوماتیک جای گذاری شد.   نمایش به صورت لینک

×   محتوای قبلی شما بازگردانی شد.   پاک کردن محتوای ویرایشگر

×   شما مستقیما نمی توانید تصویر خود را قرار دهید. یا آن را اینجا بارگذاری کنید یا از یک URL قرار دهید.

×
×
  • اضافه کردن...