WordPress Theme Design Tutorial-2

In this tutorial we show you how to callback the content to index.php file. First see the tutorial part-1.  In the previous lesson we create two files index.php and style.css. Now we work with index.php file.

Install the theme and edit index.php

Now install or active the theme that you create. Then open the index.php file by text editor. see this video:

Now copy the following code and paste to your index.php file.

——————————————————————————–

<?php

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

<h2> <?php the_title(); ?>

<?php the_excerpt(): ?>
<?php endwhile;

else:

echo ‘<p>no ontent found</p>’;

endif;

?>

——————————————————————————–

After pasting above code to your index.php file then visit your site.  You will see the content and headlines of your site. If you have no content in your site. Please create post one or two, then see your site.

Header and footer

To showing default header write this code above previous code

<?php get_header(); ?>

Now showing default footer you need to write the following code

<?php get_footer(): ?>

Now your index.php is looks like as follows:

——————————————————————————–

<?php get_header(); ?>

<?php

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

<h2> <?php the_title(); ?>

<?php the_excerpt(): ?>
<?php endwhile;

else:

echo ‘<p>no ontent found</p>’;

endif;

?>

<?php get_footer(): ?>


If you have any questions please put a comment in the comments box. Please don’t hesitate to ask me by comments.  Free WordPress Theme.

ABOUT MY TUTORIAL

This is a step by step tutorial. To learn wordpress theme development tutorial series one after another. You can follow my YouTube  Channel.

One Reply to “WordPress Theme Design Tutorial Part-2”

Leave a Reply

Your email address will not be published. Required fields are marked *