am trying to make grid view of posts for a specific category any one to help

<?php
$args = array(
'post_type' => 'post',
'category_name' => 'featured',
'posts_per_page' => 5,
'post__not_in' => get_option( 'sticky_posts' )
);
$the_query = new WP_Query( $args );?>
有帮助吗?

解决方案

You need to build the query and then loop through it afterwards.

<ul>
<?php
//Your Args
    $args = array(
    'post_type' => 'post',
    'category_name' => 'featured',
    'posts_per_page' => 5,
    'post__not_in' => get_option( 'sticky_posts' )
    );

    // The Query
    $query = new WP_Query( $args );

    // The Loop
    while ( $query->have_posts() ) {
        $query->the_post();
        echo '<li>' . get_the_title() . '</li>';
    }
?>
</ul>

Then where the code echos the title, you would include your HTML to build your grid. And obviously have extra CSS elsewhere to style it as a grid.

许可以下: CC-BY-SA归因
scroll top