Bird
Raised Fist0
Wordpressframework~5 mins

Theme from scratch setup in Wordpress - Cheat Sheet & Quick Revision

Choose your learning style10 modes available
Recall & Review
beginner
What is the first step in creating a WordPress theme from scratch?
Create a new folder in the wp-content/themes directory with your theme's name.
Click to reveal answer
beginner
What is the purpose of the style.css file in a WordPress theme?
It defines the theme's styles and contains the theme header comment that tells WordPress about the theme's name, author, and version.
Click to reveal answer
beginner
Which file is required to make a WordPress theme functional and display content?
The index.php file is required as the main template file to display content.
Click to reveal answer
beginner
How do you tell WordPress about your theme's details like name and author?
By adding a comment block at the top of style.css with details like Theme Name, Author, Description, and Version.
Click to reveal answer
intermediate
Why is it important to use semantic HTML and accessibility features in your WordPress theme?
It helps all users, including those with disabilities, to navigate and understand your site better, improving usability and SEO.
Click to reveal answer
What folder should your new WordPress theme be placed in?
Awp-content/themes
Bwp-content/plugins
Cwp-includes
Dwp-admin
Which file must contain the theme header comment with the theme name?
Aindex.php
Bfunctions.php
Cheader.php
Dstyle.css
What is the main template file that WordPress uses to display content if no other templates exist?
Asingle.php
Bindex.php
Cpage.php
Darchive.php
Which of these is NOT a required file to start a basic WordPress theme?
Astyle.css
Bindex.php
Cfunctions.php
Dnone of the above
Why should you use semantic HTML tags in your theme?
ATo improve accessibility and SEO
BTo make the site load faster
CTo reduce CSS file size
DTo avoid using JavaScript
Describe the basic files and folder structure needed to set up a WordPress theme from scratch.
Think about where the theme lives and what files WordPress needs to recognize it.
You got /3 concepts.
    Explain why accessibility and semantic HTML are important when building a WordPress theme.
    Consider who uses your website and how they interact with it.
    You got /3 concepts.

      Practice

      (1/5)
      1. What is the minimum required file to create a basic WordPress theme from scratch?
      easy
      A. style.css
      B. functions.php
      C. header.php
      D. footer.php

      Solution

      1. Step 1: Understand WordPress theme basics

        A WordPress theme must have a style.css file to be recognized by WordPress.
      2. Step 2: Identify the minimum files

        While index.php is also needed for templates, style.css is the absolute minimum to register the theme.
      3. Final Answer:

        style.css -> Option A
      4. Quick Check:

        Minimum theme file = style.css [OK]
      Hint: Remember: style.css registers the theme in WordPress [OK]
      Common Mistakes:
      • Thinking functions.php is mandatory for a basic theme
      • Confusing header.php as required initially
      • Assuming footer.php is needed to start
      2. Which of the following is the correct way to include the header template in a WordPress theme file?
      easy
      A. include('header.php');
      B. load_header();
      C. require('header.php');
      D. get_header();

      Solution

      1. Step 1: Recall WordPress template functions

        WordPress provides get_header() to load the header.php template properly.
      2. Step 2: Compare with PHP includes

        Using include or require bypasses WordPress hooks and is not recommended.
      3. Final Answer:

        get_header(); -> Option D
      4. Quick Check:

        Use get_header() to load header template [OK]
      Hint: Use get_header() for proper WordPress header loading [OK]
      Common Mistakes:
      • Using PHP include instead of get_header()
      • Trying to call a non-existent load_header() function
      • Using require which skips WordPress hooks
      3. Given this code snippet in index.php of a WordPress theme:
      <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
        <h2><?php the_title(); ?></h2>
      <?php endwhile; else : ?>
        <p>No posts found.</p>
      <?php endif; ?>

      What will be displayed if there are no posts?
      medium
      A. Nothing will be displayed
      B. An error message
      C. No posts found.
      D. The titles of all posts

      Solution

      1. Step 1: Understand the have_posts() check

        The code checks if posts exist with have_posts(). If none, it runs the else block.
      2. Step 2: Identify the else block output

        The else block outputs <p>No posts found.</p> when no posts exist.
      3. Final Answer:

        No posts found. -> Option C
      4. Quick Check:

        No posts triggers else output [OK]
      Hint: If no posts, the else block runs showing 'No posts found.' [OK]
      Common Mistakes:
      • Assuming no output if no posts
      • Expecting an error message instead
      • Thinking titles show even if no posts
      4. You created a new theme but WordPress shows a blank page. Which of the following is the most likely cause?
      medium
      A. Missing style.css file with theme header comment
      B. Using get_footer() instead of footer.php
      C. Calling get_header() twice in index.php
      D. Not adding functions.php file

      Solution

      1. Step 1: Check theme registration requirements

        WordPress requires style.css with a proper header comment to recognize the theme.
      2. Step 2: Understand blank page cause

        If style.css is missing or header comment is absent, WordPress won't load the theme, showing a blank page.
      3. Final Answer:

        Missing style.css file with theme header comment -> Option A
      4. Quick Check:

        Missing style.css causes blank theme page [OK]
      Hint: Always include style.css with header comment to register theme [OK]
      Common Mistakes:
      • Thinking get_footer() usage causes blank page
      • Assuming duplicate get_header() breaks theme
      • Believing functions.php is mandatory for theme to load
      5. You want to create a WordPress theme from scratch that shows a custom message only on the homepage and lists post titles on other pages. Which code snippet correctly implements this in index.php?
      hard
      A. <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h2><?php the_title(); ?></h2> <?php endwhile; else : ?> <p>Welcome to my custom homepage!</p> <?php endif; ?>
      B. <?php if ( is_front_page() ) : ?> <p>Welcome to my custom homepage!</p> <?php else : if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h2><?php the_title(); ?></h2> <?php endwhile; endif; endif; ?>
      C. <?php if ( is_home() ) : ?> <p>Welcome to my custom homepage!</p> <?php else : ?> <h2>No posts to show</h2> <?php endif; ?>
      D. <?php if ( is_front_page() ) : ?> <p>Welcome to my custom homepage!</p> <?php endif; ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h2><?php the_title(); ?></h2> <?php endwhile; endif; ?>

      Solution

      1. Step 1: Use conditional tags correctly

        is_front_page() checks if the current page is the homepage to show the custom message.
      2. Step 2: Show posts only on other pages

        Else block runs the loop to list post titles on non-homepage pages.
      3. Step 3: Verify code structure

        <?php if ( is_front_page() ) : ?> <p>Welcome to my custom homepage!</p> <?php else : if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h2><?php the_title(); ?></h2> <?php endwhile; endif; endif; ?> nests the else with have_posts() loop correctly, showing message only on homepage.
      4. Final Answer:

        The nested if-else code snippet -> Option B
      5. Quick Check:

        Conditional homepage message + posts elsewhere = <?php if ( is_front_page() ) : ?> <p>Welcome to my custom homepage!</p> <?php else : if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h2><?php the_title(); ?></h2> <?php endwhile; endif; endif; ?> [OK]
      Hint: Use is_front_page() for homepage, else loop for posts [OK]
      Common Mistakes:
      • Putting posts loop inside homepage condition
      • Showing message only when no posts exist
      • Not separating homepage and other pages logic
      Recommended

      Ready to prove it?

      Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

      10 questions~5 mineasy hard