我尝试了一些不同的操作,但被卡住了。
我想在循环中添加缩略图/特色图像。如果可能的话,网站摘录也要
。
这是我所拥有的:
function subsites_list_sites() {
$subsites = get_sites();
$returnHtml = '';
if ( ! empty ( $subsites ) ) {
$returnHtml .= '<div class="subsites-container">';
foreach( $subsites as $subsite ) {
$subsite_id = get_object_vars( $subsite )["blog_id"];
$subsite_name = get_blog_details( $subsite_id )->blogname;
$subsite_link = get_blog_details( $subsite_id )->siteurl;
$returnHtml .= '
<div class="subsite-item site-' . $subsite_id . '">
<div class="thumb"><a href="' . $subsite_link . '">Here i want the featured image/thumbnail to display</a></div>
<div class="wrapper">
<div class="title">
<a href="' . $subsite_link . '"><h3 class="title">' . $subsite_name . '</h3></a>
</div>
<div class="content">
<a class="excerpt" href="' . $subsite_link . '"><p>Here i want excerpt<p></a>
<a class="btn-link" href="' . $subsite_link . '">GO TO WEBSITE</a>
</div>
</div>
</div>';
}
$returnHtml .= '</div>';
}
return $returnHtml;
}
add_shortcode( 'subsites_list_sites_sc', 'subsites_list_sites' );