日期:2016-03-02 阅读:2768
dmandwp系统 - wordpress系统和DM系统区块建站>>
关于缩略图片:
add_image_size( 'featured-blog-large', 750, 350, true ); --- 可以加图片风格
在详情页可以:
<?php if ( has_post_thumbnail() )
the_post_thumbnail( 'thumbnail' );?>
在列表页,可以:
get_the_post_thumbnail( $post->ID, $size, array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ) ) )
----------
关于附件图片,比如产品的相册,一般在详情页:
相册的图片字段,可以用插件来实现,
可以通过pods这个插件来实现。 内容类型也可以用它。以前讲过types,觉得这个太点卡,就不用了。
通过wp_get_attachment_image_src得到文章的图片数组:
相册的文件,可能做到另一个文件里,再用 get_template_part( 'template-parts/post/newscontentalbum');来调用。
在详情页代码::
$postid = the_ID();
$album = get_post_meta( $post->ID,'album');
if($album[0]<>''){ //---可能用这个来判断下
//pre($album);
foreach ($album as $v) {
//pre($v);
$imgid = $v['ID'];
$image_attributes_thumbnail = wp_get_attachment_image_src( $imgid, 'thumbnail' );
//large thumbnail medium --这是默认的三个风格。
// pre($image_attributes_large); $image_attributes_large是数组,打印下就明白了。
$smallimg = $image_attributes_thumbnail[0];
}
}
上面代码,给合前端效果,就可以实现产品的相册或放大镜效果。
-------------