@ You know the category name want to know the category ID :
<?php $cat_id=get_cat_ID("style"); echo $cat_id; ?>@ You know the category name of category ID want to post Name, post ID, featured image, post content:
<?php $posts_array = get_posts( $args ); ?>Here is the definition of the $arg:
<?php $args = array( 'numberposts' => 5, 'offset' => 0, 'category' => , 'orderby' => 'post_date', 'order' => 'DESC', 'include' => , 'exclude' => , 'meta_key' => , 'meta_value' => , 'post_type' => 'post', 'post_mime_type' => , 'post_parent' => , 'post_status' => 'publish', 'suppress_filters' => true ); ?>I think it will be better to see an Example:
global $post;
-
<?php
$cat_id=get_cat_ID("style"); // get the category Id
echo $cat_id; // print the category Id
$args = array( 'numberposts' => 9,'order'=> 'ASC','category' => $cat_id );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post);
echo $post->ID; // print the Post ID
?>
- <?php the_title(); ?> <?php $feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );// get the Featured image echo "