我想補充以下後頁特色圖片框的註釋,他說WordPress的 - 下面添加說明,特色圖片
「推薦圖像尺寸:1300px(寬)×340px(高度)
在wordpress 4.2.2中可能嗎?
該文本是爲管理員用戶提供更好的指導。
任何幫助,高度讚賞。提前致謝。
我想補充以下後頁特色圖片框的註釋,他說WordPress的 - 下面添加說明,特色圖片
「推薦圖像尺寸:1300px(寬)×340px(高度)
在wordpress 4.2.2中可能嗎?
該文本是爲管理員用戶提供更好的指導。
任何幫助,高度讚賞。提前致謝。
你應該去wp-admin->includes->post.php
和周圍線1295(根據版本),你會發現:
if (!empty($thumbnail_html)) {
$ajax_nonce = wp_create_nonce('set_post_thumbnail-' . $post->ID);
$content = sprintf($set_thumbnail_link, $upload_iframe_src, $thumbnail_html);
$content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html__('Remove featured image') . '</a></p>';
}
將其更改爲:
if (!empty($thumbnail_html)) {
$ajax_nonce = wp_create_nonce('set_post_thumbnail-' . $post->ID);
$content = sprintf($set_thumbnail_link, $upload_iframe_src, $thumbnail_html);
$content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html__('Remove featured image') . '</a><span style="display:block;">Recommended image size: 1300px (width) x 340px (height)</span></p>';
}
不建議改變的核心文件,您的更改可能會在更新過程中丟失,但我不建議僅爲此小改動創建插件。
如果你想在不編輯核心文件的情況下做到這一點,你可以使用jQuery來添加文本。
add_action('admin_footer', function() {
global $pagenow;
if('post.php' == $pagenow || 'post-new.php' == $pagenow) : ?>
<script>
jQuery(document).ready(function($) {
$('#postimagediv .inside').after('<div style="padding: 0 12px 12px;">Recommended image size: 1300px (width) x 340px (height)</div>');
});
</script>
<?php endif;
});
該解決方案不像在PHP文件中直接進行更改那樣「乾淨」,但我認爲最好是編輯核心。有了這個解決方案,您不必擔心WordPress更新後重新制作更改。
非常感謝。是的,這是一個小小的變化,所以編輯核心文件更好。 – Raj