• Resolved drphil9001

    (@drphil9001)


    I have just decided to take advantage of WordPress’s capability to do CMS and am migrating my entire website over to be based on WordPress.

    I have converted the style sheets, and have templates for page.php, home.php, header.php, footer.php, etc. The home page of my site is not my blog entries and is not a separate page in WP pages. It is simply generated from home.php.

    Everything seems to be working fine, but now I want to be able to have a link that will show users blog entries. I thought that I could create a template called blog.php and then could have a link to http://myurl/blog/. However, when I visit the link, I get a 404 error. The contents of blog.php are at least initially the the contents of the default index.php.

    Can someone please give me some pointers on how I can accomplish this?

    Thanks,
    Phil

Viewing 7 replies - 1 through 7 (of 7 total)
  • No, you can NOT use blog.php instead of index.php. WP is looking for that file. Also, index is the general fallback file if any of the template files are missing.
    Learn: Template_Hierarchy.
    Also, if you have a home.php INSIDE the theme folder – that will take precedence over index.php and will want to appear as your blog’s main page.

    I still don’t understand how do you want to set up your site, so I am not sure what kind of advice to give you…

    Thread Starter drphil9001

    (@drphil9001)

    Thanks for the reply. I do indeed have an index.php file and understand the general concept of how the themes and various templates work.

    So here is what I am trying to do. I have a general site layout that I want to implement consisting of, say, a home page, an “about us” page, a “products” page, and a pages for my blog.

    The home page is done via home.php.

    The “about us” and “products” pages are Pages (with a capital P) in the WP pages that were created through the admin page. They are using page.php as their template.

    I also have the header.php and footer.php, as well as the sidebar.php customized along with the styles.css.

    In the header I want to have a link to, say, mysite.com/blog/ that will have its own template (called blog.php) that will render the blog posts from WP.

    Does that make any more sense?

    I also tried to create a dummy Page in WP admin called “blog” to see if it would then pick up the custom template. From reading through the Template Hierarchy it looks like this should work. But it doesn’t seem to be seeing the custom page template.

    Any ideas?

    Thanks,
    Phil

    Make blog.php a Page template > see Pages. Then make a new Page (Blog?) using this new template.
    Then in the Options > Reading select it as your posts page.

    Thread Starter drphil9001

    (@drphil9001)

    OK, so I was missing the “Template Name” comment at the beginning of the blog.php file and now WP sees it as a template and I can select it for the “Blog” page.

    When I view the page it is formatted as a regular posts page in WP, however, the content for the page is coming from the content that was entered in the editor on the “Write Page” page and not the posts that are in WP.

    Also, when I change the Options>Reading options, the Blog page now looks like the Home page and I needed to create a “Home” page as a WP Page to select it, and now WP seems to be using page.php instead of home.php to render it.

    Is there a way that I can ignore this content and replace it in the Blog.php page with the actual blog posts? And still have home.php be used for the homepage?

    however, the content for the page is coming from the content that was entered in the editor on the “Write Page” page and not the posts that are in WP.
    You should NOT enter anything in the content!

    ———
    as for the other question… I never tried to assign ONLY a posts page without having a “main/front page” also selected.

    But can’t you make home.php a Page template – perhaps just renaming it and adding the lines at the top?

    Thread Starter drphil9001

    (@drphil9001)

    Thanks for all your help!

    With your suggestions and this final hack I just found, I now have the desired behavior.

    First, I did not change anything on the Reading options pane. It still has the default settings.

    I have home.php that renders my sites homepage.

    I added

    $post_query=new $WP_Query('showposts=10')

    prior to The Loop on my Blog.php page. Now instead of looping the content on the Page itself, it gets the posts that are in the blog.

    Thread Starter drphil9001

    (@drphil9001)

    I thought that I had resolved this post, but have now, with further testing, come to the conclusion that it is not yet resolved completely.

    Check out this post: http://wordpress.org/support/topic/148349?replies=1

    And you get the idea of what is going on. On my custom blog page, the pagination is not working properly. I am using a new WP_Query object to perform the query. If I use query_posts() the page crashes at the call to query_posts() and results in a blank page.

    I also went back and tried to set the posts page in the reading options. When that is set and I click on the link to the Blog, I am sent back to the home page via home.php.

    Once again, any help on this would be greatly appreciated.

    Thanks,
    Phil

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Custom Blog page’ is closed to new replies.