I have custom my template and trying to convert my html into wordpress template, i have created one page page-grid.php .and i want to show all my post with images .but don't know how to do this .and where to put my scripts.my html is having diffrenet background color whenyou scoll all post. can anybody help guide me?


$args = array(
'post_type' => 'put your custom PostType name here',
'posts_per_page' => '-1'

$query = new WP_Query( $args );

if ( $query->have_posts() ) {

    while ( $query->have_posts() ) {


        // Contents of the queried post results go here.



// Restore original post data.


You can use wordpress WP_Query class to loop through all posts.

// the query
   $args = array('post_type'=> 'post')
    $the_query = new WP_Query( $args ); ?>

<?php if ( $the_query->have_posts() ) : ?>

    <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
        <h2><?php the_title(); ?></h2>
        <?php the_content(); ?>
    <?php endwhile; ?>
    <!-- end of the loop -->

    <!-- pagination here -->

<?php the_posts_navigation(); ?>

    <?php wp_reset_postdata(); ?>

<?php else : ?>
    <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>

or if you are new to wordpress then you can make child theme of any wordpress theme, where you can use WordPress code and modify it as you like. Really child theme is very good concept of wordpress for easily making theme.

Hope this will help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.