Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • WP_Query for post

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 187
    Comment on it

    Here is the code to get your custom post type posts. you can put something which you want to print like your post content, your post title, featured image and etc under the while loop.

     'news',          // Change news as your post type
        'post_status'            => 'publish',
        'cat'                    => '3',            // Change 3 as your cat id
    );
    // The Query
    $query = new WP_Query( $args );
    // The Loop
    if ( $query->have_posts() ) {
        while ( $query->have_posts() ) {
            $query->the_post();
            // do something
        }
    } else {
        // no posts found
    }
    // Restore original Post Data
    wp_reset_postdata();
    ?>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: