这是一个非常奇怪和严重的问题。转到我的管理区域中的“所有图像” (相当于所有帖子)显示内存耗尽错误和白屏。这是在将内存增加到非常高的数量之后。
我想我想知道为什么需要这么多内存来构建一个简单的列表?
我认为这一定是我的错误,编码。也许我在声明帖子类型时做错了什么?这个领域有哪些常见的“陷阱”?我不想只说“增加内存”,因为对于一个严重的问题来说,这似乎是一个弱小的工作。
add_filter( 'manage_edit-image_columns', 'symbiostock_image_manager_edit_columns' );
function symbiostock_image_manager_edit_columns( $columns )
{
$columns = array(
'cb' => '<input type="checkbox" />',
'image_preview' => 'Preview',
'date' => 'Uploaded',
'title' => 'Image Name',
'description' => 'Description',
'exclusive' => 'Exclusive',
'price_bloggee' => 'Bloggee',
'price_small' => 'Small',
'price_medium' => 'Medium',
'price_large' => 'Large',
'price_vector' => 'Vector',
'cat' => 'Category',
'tag' => 'Keywords'
);
return $columns;
}
add_action( 'manage_image_posts_custom_column', 'symbiostock_image_manager_custom_columns' );
function symbiostock_image_manager_custom_columns( $column )
{
global $post;
$custom = get_post_custom();
switch ( $column ) {
case 'date':
break;
case 'image_preview':
echo '<img class="admin_preview_pic" alt="Image Preview" src="' . $custom['symbiostock_minipic'][0] . '" />';
break;
case 'description':
the_excerpt();
break;
case 'exclusive':
echo $exclusive = ucwords(str_replace('_', ' ', $custom[ "exclusive" ][ 0 ]));
break;
case 'discount_percent':
echo $discount_percent = $custom[ "discount_percent" ][ 0 ];
break;
case 'price_bloggee':
echo $price_bloggee = $custom[ "price_bloggee" ][ 0 ];
break;
case 'price_small':
echo $custom[ "price_small" ][ 0 ];
break;
case 'price_medium':
echo $custom[ "price_medium" ][ 0 ];
break;
case 'price_large':
echo $custom[ "price_large" ][ 0 ];
break;
case 'price_vector':
echo $custom[ "price_vector" ][ 0 ];
break;
case 'cat':
echo get_the_term_list( $post->ID, 'image-type', '', ', ', '' );
break;
case 'tag':
echo get_the_term_list( $post->ID, 'image-tags', '', ', ', '' );
break;
} //$column
}
也许我如何声明自定义帖子类型存在问题。这是代码以防万一:
register_taxonomy( 'image-tags', array(
'image'
), array(
'hierarchical' => false,
'rewrite' => true,
'query_var' => true,
'singular_label' => 'Image Keyword',
'exclude_from_search' =>false,
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'slug' => 'image-tag',
'labels' => array(
'name' => _x( 'Image Keywords', 'taxonomy general name' ),
'singular_name' => _x( 'Keywords', 'taxonomy singular name' ),
'search_items' => __( 'Search Images' ),
'all_items' => __( 'All Image Keywords' ),
'edit_item' => __( 'Edit Image Keyword' ),
'update_item' => __( 'Update Image Keyword' ),
'add_new_item' => __( 'Add New Image Keyword' ),
'new_item_name' => __( 'New Keyword Name' ),
'menu_name' => __( 'Image Keywords' ),
),
'rewrite' => array(
'slug' => 'search-images', // This controls the base slug that will display before each term
'with_front' => false,
),
) );