• Resolved lizhaozhi

    (@lizhaozhi)


    I’m new to WordPress and following a video tutorial to convert my HTML template into a WordPress theme. I building on localhost with wampserver. I have created a theme folder in the WordPress themes folder and given it a name. I have also created files according to the WordPress documentation. Now I have these files in the folder:

    – index.php
    – page.php
    – single.php
    – functions.php
    – header.php
    – footer.php
    – style.css

    I’ve configured the style.css file correctly. I can tell this because I was able to get WordPress to recognise the custom theme that I just created and have the theme activated.

    So far, only style.css and index.php have content. All other files are empty. I have <?php echo "Hello world"; ?> in index.php. When I launch the website at localhost/wordpress/, I got a completely blank page, but when I open localhost/wordpress/functions.php, everything shows up (Hello world).

    I’m following the video, so at this point the Hello world message should be showing up at localhost/wordpress/ but not localhost/wordpress/functions.php.

    What can possibly go wrong with this setup? Remember, <?php echo "Hello world"; ?> is the only line of code I have. I don’t believe it’s an PHP error.

    • This topic was modified 2 years, 9 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 2 replies - 1 through 2 (of 2 total)
  • The functions.php file belongs in your theme folder, not the root of your WordPress installation.

    Also, I’m not a developer and I may be totally wrong on this… but I believe you need to run the WordPress loop for WordPress to display anything.

    Finally, you want to turn on WordPress debugging and check your webserver’s access and error logs when developing to know what’s going on behind the scenes to help with troubleshooting.

    And, by the way, the WordPress theme development train is moving. What you’re learning and doing is for traditional theme’s. The future is block-based theme’s for full-site editing, and if I were learning WordPress theme development afresh today, that’s where I’d start from.

    Thread Starter lizhaozhi

    (@lizhaozhi)

    Hi @gappiah George, thank you for the response, links and suggestions. A loop is not required for displaying stuff in WordPress. It’d be used for looping through posts and display them. In my case, I have nothing but one line of code (message) to display. And, you’re right about functions.php belonging to the theme folder, and that’s where I put the file. I just don’t understand why my code in index.php produces output in this file instead.

    I’ve actually solved the problem but still don’t understand the root cause. I would appreciate continuous contribution to this thread that helps uncover the myths. I’m using the latest version of WordPress, so I’ve heard of the block-based theme. I will certainly check that out but will complete my current tutorial first, one step at a time.

    For those newbies and veterans who might also have run into this issue, I’m sharing how I fixed the white screen of death (somehow):

    I just downloaded WordPress from this website, unzipped and folder and moved it into Wampserver’s www folder (If you’re using XAMPP, it could be a different location.). Then I followed the steps to set up a database and local WordPress profile. By default, it uses a pre-installed template with some pages already there. Before I came up with the idea of converting static designs into WordPress themes, I installed WooCommerce, WP ERP and a few other plugins. These plugins created new pages. Then I disabled the plugins but the pages remain on my default website. After that I followed the video and converted my template into a WordPress theme by creating folder, files and coping code into the WordPress themes folder. This created the white screen of death. Then I deleted all the existing pages from the pages tab in admin, the problem was resolved. When I added the pages back, the site remains accessible. At this point, the problem should have been fixed.

    In conclusion, I recommending removing (trashing or converting to draft) all the existing pages from your WordPress admin before deploying custom themes. This could help solving your problem.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom WordPress theme front page displays in wrong location’ is closed to new replies.