Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress

Issue on display all the pages

I am almost done with WordPress Theme Functions, but can not find my mistake. Even though I included menus and posts, I can not see it on my local server. The path is right and on themes/edit code i can see all the files are right. Also I activated my custom themes and i can see it on dashboard. For example: When i go to localhost/wp_project/home, nothing even there is some codes with menus.

What are the reasons that single-post.php or home.php files would not show anything?

3 Answers

John Locke
John Locke
15,479 Points

Hi Dungaamaa:

When you View the Source code of the pages in question, is there anything there, or partially there?

All the source code is there , when i go to edit and i can see it on dashboard. All the directories in place.

John Locke
John Locke
15,479 Points

Okay, you have your PHP templates visible on your Dashboard/ Admin view, what you mean is that you can't see it in your server directory, is that right?

Yes. You know when i typein localhost/ go to my theme directory and want to view my page and nothing shows.

John Locke
John Locke
15,479 Points

OK, when you go to view your site in the browser, right click and View Page Source. Is there HTML there? If so, does it look like it is complete or no?

what if i dont see page source in the browser?

John Locke
John Locke
15,479 Points

Do other pages display, or are they all empty, with no source code behind them?

All the source codes are empty. It could be related to my folder. Because when i go to localhost and there are 3 folders. The one i am working on is "wordpress_theme1" and when i click , it shows server error. On admin area i can see all the files, but no contents.

What did i do wrong? Seems directories not connected or its code error.

John Locke
John Locke
15,479 Points

Sometimes WordPress themes refer to the name of the theme folder in a bunch of different templates. If you started the project with a theme folder with a specific name, and it worked then, you might try changing that back.

Let me know how you started the project and at what point it stopped working.

I changed main folder name once and it worked when i added get_footer and get_header inside front-page.php. After i added :

<?php get_header(); ?>

<p>This is front-page.php</p> <?php if ( have_posts() ): while ( have_posts() ) : the_post(); ?>

<h3><?php the_title(); ?></h3> <?php the_content(); ?> <hr> <?php endwhile; else: ?> <p>There are no posts or pages here.</p> <?php endif; ?> <?php get_footer(); ?>

It start give me server error.

John Locke
John Locke
15,479 Points

If you have a copy of the original templates you started with, try putting those back. Be sure to save copies of the templates you have now for looking at later. This is something I do a lot, to make sure I can backtrack to a safe place before I make changes.

If you can back to a place where things work, try changing lines a little bit at a time, and make sure that things keep working.

It's a theme from scratch and i was following Zac Gordon 's videos.

I deIete all and started over and found my mistakes. First of all <p>This is Header</p> <?php

$args = array (
        'menu' => 'main-menu'
        );
wp_nav_menu( $args );

?>

wrong name on main-menu

Second wrong code in wrong php file

Now its working :)

John Locke
John Locke
15,479 Points

Glad you got this working., Dungaamaa. I still learn by digging in the code, making small changes, and seeing what happens.