如何解决从 Wordpress 多站点网络中的另一个站点获取特定类别中的帖子
global $switched;
switch_to_blog(4); //switched to 4
// Get latest Post
$latest_posts = get_posts('category=-28&numberposts=6&orderby=post_name&order=DSC');
$cnt =0;?>
<?PHP foreach($latest_posts as $post) : setup_postdata($post);?>
<?PHP
// do something
echo('<div style="position:relative;padding:20px;margin-bottom:20px;background:rgb(249,249,249) url(https://cra.org/crn/wp-content/uploads/sites/7/2016/01/cerp-back-faint.png) no-repeat right bottom;
border-top: 2px solid #1b806e;
">');
echo('<h4 style="font-size:16px;margin:5px 0 5px 0;"><a style="color:#1b806e!important;text-decoration:none" href="');
the_permalink();
echo('" title="');
the_title_attribute();
echo('">');
the_title();
echo('</a></h4>');
if( get_post_meta($post->ID,'byline',true) ) {
echo ('<em>By ');
echo get_post_meta($post->ID,true);
echo ('</em>');
}
if (has_post_thumbnail( $post->ID ) ) {
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ),'single-post-thumbnail' );
echo '<a href="'; the_permalink(); echo '" title="'; the_title_attribute(); echo '">';
echo '<img style="padding:1em" align="right" width="100" src="' . $image[0] . '">';
echo '</a>';
}
the_excerpt();
// read more button
echo '<small><a style="font-size: 10px !important;padding: 6px 10px;margin: 0 1px 1px 0;border-style: solid;border-width: 1px;border-color: #eee;text-decoration: none;color: #f9f9f9;background: #75accb;text-transform: uppercase;border-radius: 20px;" href="';
the_permalink();
echo '" title="';
the_title_attribute();
echo '">Read More</a></small>';
?>
</div>
<?PHP endforeach ; ?>
<?PHP restore_current_blog(); //switched back to main site ?>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。