如何在WordPress的边栏中显示所选类别的书籍,而无需任何插件。
我想在侧边栏(网页)中显示其类别通过复选框或诸如此类从小部件(管理员)激活的书籍。
<?php
// Start the loop. 4 is catid
//write this code in your theme sidebar.php file
$the_query = new WP_Query('cat=4' );
while ( $the_query->have_posts() ) : $the_query->the_post();
$postId = get_the_ID();
?>
<div class="blog_cell">
<div class="row">
<div class="col-xs-12 col-sm-8 col-md-8 col-lg-7">
<span class="profile"><i class="fa fa-user" aria-hidden="true"></i> <?php the_author(); ?></span> <span class="comments"><i class="fa fa-comment" aria-hidden="true"></i> <?php comments_number( 'no comment', 'One Comment', '% responses' ); ?></span>
<h4><?php the_title(); ?></h4>
<p class="blog-info">
<?php
$content = get_the_content();
$content = substr(strip_tags($content),0,300);
echo $content;
?>
</p>
<a class="read-blog" href="<?php the_permalink(); ?>"> Read More <i class="fa fa-angle-double-left" aria-hidden="true"></i> </a>
</div>
<div class="col-xs-12 col-sm-4 col-md-4 col-lg-5">
<?php
if(has_post_thumbnail())
{
the_post_thumbnail();
}
else
{
?>
<img src="http://essusinnovations.com/wp-content/themes/essus/images/blog1.jpg" class="img-responsive image">
<?php
}
?>
</div>
</div>
</div>
<?php
endwhile;
wp_reset_query();
?>