從零開始建立WordPress主題
This is going to be a fun tutorial where we inspect how to create your own WordPress Theme from scratch. In fact, we'll begin with absolutely zero files and zero lines of code. The only way to understand how WordPress Themes work, is to really jump in at a low level and do every single…內容出處: WordPress Theme Development Tutorial Step By Step – Vegibit
Step 1: Create a folder to hold your theme files
在wp-content下的theme建立一個新資料夾,例如,mythemeStep 2: Create style.css and index.php in your theme folder
建立 style.css/* Theme Name: mytheme Author: Wells Author URI: https://ace.ita.hk.edu.tw Version: 1.0 */
建立 index.php
<h1>Custom Theme!</h1>
Step 3: Activate your theme from the WordPress Dashboard
Step 4: Add Code to Output The Post Title and Post Text
index.php修改成如下的程式碼:<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h2><?php the_title() ?></h2> <?php the_content() ?> <?php endwhile; else : echo '<p>There are no posts!</p>'; endif; ?>
Step 5: Add a Link To Each Post 為每一則貼文加上超連結(打開每一則貼文)
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h2><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h2> <?php the_content() ?> <?php endwhile; else : echo '<p>There are no posts!</p>'; endif; ?>