2010-10-12 46 views
0

我已關閉頁面中的評論,但仍在頁面中顯示下面的行。如何禁用這些行。有人請幫助我!如何在wordpress頁面中隱藏完整註釋

發表於十月12,2010 by sankar 評論關閉|編輯 評論被關閉。

+0

可能是superuser.com的情況。 – mnuzzo 2010-10-12 18:59:47

回答

3

你使用的WP版本是什麼?

在WP 3+(也許更早)你只是去到儀表板,單擊頁,單擊編輯有問題的頁面,向下滾動到討論的部分,並取消允許評論&允許引用通告&包括引用盒。然後垃圾附加到頁面的任何評論。

如果你實際上意味着而不是,那麼保羅就是在正確的一個小修改的主題將是必要的。注意:只要有可能,請使用兒童主題來做到這一點,這樣您就不會不小心敲擊主題。

假設您使用的是WP 3和默認的Twenty Ten主題,請編輯wp-content/themes/twentyten/comments.php(或創建一個子主題,複製comments.php,然後繼續)。

的comments.php,行70,上寫着:

if (! comments_open()) : 

更改它讀取:

if (0 && ! comments_open()) : 

這有效地殺滅線後,這也正是 「評論被關閉」 輸出,但沒有完全刪除它。很明顯,如果你使用的是不同的主題,你必須在自己的comments.php中搜索相應的行。

請注意,這是一個快速和骯髒的黑客將影響所有職位。如果您只想爲選定的帖子執行此操作,您必須做更多的工作。

0

您需要編輯顯示出模板外的行。

0

最簡單的方法是找到theme/page.php中的以下行並刪除或註釋它。

<?php comments_template('', true); ?> 
1

轉到Wordpress頁面 - 單擊「快速編輯」,您將看到選項給予註釋的刻度標記,可以避免該刻度標記。

yourdomainname.com /wp-admin/edit.php?post_type=page

然後每個頁面的

點擊快速編輯。

3

將此代碼添加到您的function.php文件

// Disable support for comments and trackbacks in post types 
function df_disable_comments_post_types_support() { 
$post_types = get_post_types(); 
foreach ($post_types as $post_type) { 
    if (post_type_supports($post_type, 'comments')) { 
     remove_post_type_support($post_type, 'comments'); 
     remove_post_type_support($post_type, 'trackbacks'); 
    } 
} 
} 

add_action('admin_init', 'df_disable_comments_post_types_support'); 

    // Close comments on the front-end 
function df_disable_comments_status() { 
return false; 
} 

add_filter('comments_open', 'df_disable_comments_status', 20, 2); 
add_filter('pings_open', 'df_disable_comments_status', 20, 2); 

// Hide existing comments 
function df_disable_comments_hide_existing_comments($comments) { 
$comments = array(); 
return $comments; 
} 

add_filter('comments_array', 'df_disable_comments_hide_existing_comments', 10, 2); 

// Remove comments page in menu 
function df_disable_comments_admin_menu() { 
remove_menu_page('edit-comments.php'); 
} 

    add_action('admin_menu', 'df_disable_comments_admin_menu'); 

// Redirect any user trying to access comments page 
    function df_disable_comments_admin_menu_redirect() { 
global $pagenow; 
if ($pagenow === 'edit-comments.php') { 
    wp_redirect(admin_url()); 
    exit; 
} 
} 

    add_action('admin_init', 'df_disable_comments_admin_menu_redirect'); 

    // Remove comments metabox from dashboard 
    function df_disable_comments_dashboard() { 
remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal'); 
} 

    add_action('admin_init', 'df_disable_comments_dashboard'); 

    // Remove comments links from admin bar 
function df_disable_comments_admin_bar() { 
if (is_admin_bar_showing()) { 
    remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60); 
} 
} 

add_action('init', 'df_disable_comments_admin_bar'); 
0

您可以編輯頁面模板。尋找get_template_part('comments')並刪除它

相關問題