我需要帮助,因为这是我新工作的第一个项目;我被困在这一点上了。
我正在使用以下代码作为短名单检索自定义帖子类型组合:
extract( shortcode_atts( array( \'limit\' => -1, \'type\' => \'post\'), $atts ) );
$paged = get_query_var(\'paged\') ? get_query_var(\'paged\') : 1;
query_posts( array (
\'posts_per_page\' => $limit,
\'post_type\' => $type,
\'order\' => \'ASC\',
\'orderby\' =>\'menu_order\',
\'paged\' => $paged ) );
$list = \' \';
while ( have_posts() ) { the_post();
$list .= \'<li class="mix all">\'
. \'<div class="listing-content">\'
. \'<h3><a href="\' . get_permalink() . \'">\' . get_the_title() . \'</a></h3>\'
.\'<p>\' . get_the_excerpt() . \'</p>\'
. \'<a href="\' . get_permalink() . \'">\' . \'View »\' . \'</a>\'
. \'</div>\'
. \'<a class="listing-thumb" href="\' . get_permalink() . \'">\' . get_the_post_thumbnail($page->ID, \'listing-thumb\') . \'<span></span></a>\'
. \'</article>\';
}
return
\'<div class="listings clearfix">\'
. $list
. \'<div class="nav-previous">\' . get_next_posts_link( __( \'<span class="meta-nav">←</span> Older posts\' ) ) . \'</div>\'
. \'<div class="nav-next">\' . get_previous_posts_link( __( \'Newer posts <span class="meta-nav">→</span>\' ) ) . \'</div>\'
. \'</div>\' .
wp_reset_query();
}
add_shortcode( \'feed\', \'section_feed_shortcode\' );
我想在以下代码点显示自定义分类法“name”:
$list .= \'<li class="mix all ####RIGHT HERE#### ">\'
有可能吗。如果是,那么也可以选择特色图片。
谢谢
最合适的回答,由SO网友:Krzysiek Dróżdż 整理而成
好的,您必须修改代码的某些部分,如下所示:
$list = \' \';
while ( have_posts() ) {
the_post();
$terms = get_the_terms( $post->ID, \'port_tags\' );
$terms_string = \'\';
if ( $terms ) {
foreach ( $terms as $term )
$terms_string .= $term->slug . \' \';
}
$list .= \'<li class="mix all \'. $terms_string .\'">\'
. \'<div class="listing-content">\'
. \'<h3><a href="\' . get_permalink() . \'">\' . get_the_title() . \'</a></h3>\'
.\'<p>\' . get_the_excerpt() . \'</p>\'
. \'<a href="\' . get_permalink() . \'">\' . \'View »\' . \'</a>\'
. \'</div>\'
. \'<a class="listing-thumb" href="\' . get_permalink() . \'">\' . get_the_post_thumbnail($page->ID, \'listing-thumb\') . \'<span></span></a>\'
. \'</article>\'; // <- it should be </li> not </article>, I guess - you don\'t open any <article> tag in this loop
}