php - Wordpress - Specific category post loop -
i want create loop post of specific category id. first post latest category , others posts under.
so have category id = "190", how posts per design? >> check design here
<!-- featured post --> <div class="module-one-typo"> <a href="#"><img src="img/sample/370x250.png?1491474115266" alt=""></a> <h3><a href="#"><b>trump names climate change skeptic , oil industry ally lead epa</b></a></h3> <h5> <span><i class="fa fa-calendar"></i> november 02, 2017 </span> <span> <i class="fa fa-comments-o"></i> 10</span> <span> eyad ashraf</span> </h5> <p>lorem ipsum dolor sit amet, consectmagna aliqua. ex ea commodo consequat. duis aute irure etur adipisicing elit, dolor in reprehenderit in voluptate velit .</p> </div> <!-- /featured post --> <!-- older post loop --> <div class="module-two-strips"> <div class="module-one-strip row align-middle"> <div class="columns shrink"><a href="#"><img src="img/sample/100x80.png" alt=""></a></div> <div class="columns"> <h5><a href="#"><b>the first pirate party created in sweden in 2006</b></a></h5> <h5> <span><i class="fa fa-calendar"></i> november 02, 2017 </span> <span> <i class="fa fa-comments-o"></i> 100</span> </h5> </div> </div> <div class="module-one-strip row align-middle"> <div class="columns shrink"><a href="#"><img src="img/sample/100x80.png" alt=""></a></div> <div class="columns"> <h5><a href="#"><b>the first pirate party created in sweden in 2006</b></a></h5> <h5> <span><i class="fa fa-calendar"></i> november 02, 2017 </span> <span> <i class="fa fa-comments-o"></i> 100</span> </h5> </div> </div> <div class="module-one-strip row align-middle"> <div class="columns shrink"><a href="#"><img src="img/sample/100x80.png" alt=""></a></div> <div class="columns"> <h5><a href="#"><b>the first pirate party created in sweden in 2006</b></a></h5> <h5> <span><i class="fa fa-calendar"></i> november 02, 2017 </span> <span> <i class="fa fa-comments-o"></i> 100</span> </h5> </div> </div> <div class="module-one-strip row align-middle"> <div class="columns shrink"><a href="#"><img src="img/sample/100x80.png" alt=""></a></div> <div class="columns"> <h5><a href="#"><b>the first pirate party created in sweden in 2006</b></a></h5> <h5> <span><i class="fa fa-calendar"></i> november 02, 2017 </span> <span> <i class="fa fa-comments-o"></i> 100</span> </h5> </div> </div> </div> <!-- older post loop -->
update:
i have visual composer shortcode function i'll take category id vc , create element this. ( $type category id value )
<?php $args = array( 'cat' => 194, //your category id 'posts_per_page' => 10 ); $the_query = new wp_query( $args ); ?> <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : the_post(); ?> <h1><?php the_title(); ?> </h1> <?php endwhile; else : ?> <p><?php _e( 'sorry, no posts matched criteria.' ); ?></p> <?php endif; ?> <!-- custom content --> <?php return ob_get_clean(); } add_shortcode('et_module', 'et_module');
that's tested far , got error. php error i'm getting
try one,
$args = array( 'cat' => 190, --> category id 'posts_per_page' => 10 ); $the_query = new wp_query( $args ); // loop if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { // ## write code here.. } }
you have put category id. if have category name, use this:
$args = array( 'category_name' => <your category name> );
Comments
Post a Comment