Is it really necessary to echo so much. If you make proper use of opening and closing php tags you can eliminate using echo. And why are you echoing get_the_title()
when there is a build in feature for that. the_title()
does exactly the same.
You can use WP_Query
to create a special loop to get posts from a specific category. Just remember to reset your loop as you are going to start a new loop. For multiple loops, also check The Loop. One word of advice, the author of this page used query_posts
, which you must not use at all, use WP_Query
As for the excerpt, you can change the read more link as follow
function new_excerpt_more( $more ) {
return ' <---the code of your button here--->';
}
add_filter( 'excerpt_more', 'new_excerpt_more' );
So in the end, your code should like like this
<?php $my_query = new WP_Query('category_name=special_cat&posts_per_page=10'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<section class="row"><div class="container-item">
<div class="item">
<div class="item-overlay">
<div class="item-content">
<div class="item-top-content">
<div class="item-top-content-inner">
<div class="item-product">
<div class="item-top-title">
<h2>
<?php the_title(); ?>
</h2><p class="subdescription">
<?php the_excerpt(); ?>
</p></div></div></div>
</div>
</div>
</div>
</div>
</div>
</section>
<?php endwhile; ?>
<?php rewind_posts(); ?>
<---Start your new loop here --->