Index.php template for WordPress theme with pagination - Brown Surfing

Index.php template for WordPress theme with pagination

Posted on: September 13th, 2022
By: Efrain Lemus

You can find more documentation here: https://developer.wordpress.org/themes/getting-started/your-first-theme/

<?php

get_header();

echo '<h1>' . get_bloginfo( 'name' ) . '</h1>';
echo '<h2>' . get_bloginfo( 'description' ) . '</h2>';

if ( have_posts() ) : while ( have_posts() ) : the_post();

echo '<h3>' . get_the_title() . '</h3>';

the_content();

wp_link_pages();

edit_post_link();

endwhile;

// default pagination from wordpress
// if ( get_next_posts_link() ) {
// next_posts_link();
// }


// if ( get_previous_posts_link() ) {
// previous_posts_link();
// }

// pagination with page numbers
the_posts_pagination( array(
    'mid_size' => 2,
    'prev_text' => __( 'Previous Page', 'textdomain' ),
    'next_text' => __( 'Next Page', 'textdomain' ),
) );

// the next two lines break the code, not sure why
// else :
// echo '<p>No posts found. :(</p>';

endif;

get_footer(); 
?>

Have any questions or comments? Write them below!


Leave a Reply

Your email address will not be published.