【发布时间】:2015-01-17 16:58:20
【问题描述】:
function portfolio_shortcode($atts, $content = null){
extract( shortcode_atts( array(
'type' => 'post',
), $atts ) );
$q = new WP_Query(
array('posts_per_page' => 5, 'post_type' => 'portfolio')
);
$list = '<div class="row">
<section id="projects">
<ul id="thumbs" class="portfolio">';
while($q->have_posts()) : $q->the_post();
$idd = get_the_ID();
$portfolio_large = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'portfolio-large' );
$portfolio_thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'portfolio-image' );
$list .= '
<!-- Item Project and Filter Name -->
<li class="col-lg-3 design" data-id="id-0" data-type="web">
<div class="item-thumbs">
<!-- Fancybox - Gallery Enabled - Title - Full Image -->
<a class="hover-wrap fancybox" data-fancybox-group="gallery" title="'.get_the_title().'" href="'.$portfolio_large[0].'">
<span class="overlay-img"></span>
<span class="overlay-img-thumb font-icon-plus"></span>
</a>
<img src="'.$portfolio_thumb[0].'" alt="'.get_the_title().'" />
</div>
</li>
';
endwhile;
$list.= '</ul></section></div>';
wp_reset_query();
return $list;
}
add_shortcode('portfolio', 'portfolio_shortcode');
【问题讨论】:
-
$post->ID->$idd->ID? -
最后一行真的是第 48 行吗?到目前为止,您尝试过什么?
-
题目中包含一个问题,而问题正文中没有其他解释性信息,往往会被关闭。
-
您的帖子中只有 41 行代码,但问题出在第 48 行...您需要向我们展示第 48 行附近的代码...