• Resolved redwoodfloors

    (@redwoodfloors)


    Greetings,

    I’m building a site and attempting to have my blog live in the sub folder blog, as in ‘website.com/blog’. I followed the instructions here. Once I apply the template of ‘blog’ to the new page called ‘blog’, everything it fails. Specifically, if I navigate to website.com/blog I get ‘index of blog’ and folders on the server. It’s as if there’s no index.php and nothing is there. If I try to navigate to a specific post, I get: ‘Parse error: syntax error, unexpected T_ENDWHILE in /home/donaldde/public_html/wp-content/themes/mytheme/single.php on line 50’

    If I create the page ‘blog’ and leave it as the default template, it’s fine. On another note, I have changed the permalinks as the article recommends. My permalinks are: /blog/%postname%

    Any help is greatly appreciated!

    Here’s the code for my custom page template:

    <?php
    /*
    Template Name: Blog
    */
    
    // Which page of the blog are we on?
    $paged = get_query_var('paged');
    query_posts('cat=-0&paged='.$paged);
    
    // make posts print only the first part with a link to rest of the post.
    global $more;
    $more = 0;
    
    //load index to show blog
    load_template(TEMPLATEPATH . '/index.php');
    
    ?>
    
    <?php get_header(); ?>
    
        <div id='contentcontainer'>
        <div id='content'>
    	<?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>
    			<div class="post" id="post-<?php the_ID(); ?>">
                    <div class="postdate">
                        <p class='postday'><?php the_time('d') ?>
    
                        <p class="postmonth"><?php the_time('M') ?>
    
                        <p class='postyear'><?php the_time('Y') ?>
    
                    </div><!--POST DATE-->
                    <div class="postcontent">
                        <h2><?php the_title(); ?></h2>
                        <?php the_content('<p class="serif">Read the rest of this page &raquo;
    '); ?>
                        <?php wp_link_pages(array('before' => '<strong>Pages:</strong> ', 'after' => '
    ', 'next_or_number' => 'number')); ?>
                    </div><!--POST CONTENT-->
                    <br class="clear" />
                </div><!--POST-->
    
                <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
                <?php the_author() ?>
    
                <?php the_content('Read the rest of this entry &raquo;'); ?>
                <?php the_tags('Tags: ', ', ', ''); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?><?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
    
    		<?php endwhile; ?>
    
    		<ul>
    			<li><?php next_posts_link('&laquo; Older Entries') ?></li>
    			<li><?php previous_posts_link('Newer Entries &raquo;') ?></li>
    		</ul>
    
        <!--NO POSTS?-->
    	<?php else : ?>
    		<h2>Not Found</h2>
    		Sorry, but you are looking for something that isn't here.
    
    		<?php include (TEMPLATEPATH . "/searchform.php"); ?>
    	<?php endif; ?>
        </div><!--CONTENT-->
        </div><!--CONTENT CONTAINER-->
    
    <?php get_footer(); ?>

Viewing 4 replies - 1 through 4 (of 4 total)
  • Why not just install WordPress in the blog folder. Essentially, public_html/blog/wp-admin, public_html/blog/wp-content, public_html/blog/wp-includes, would be how your directory structure would appear.

    Then after installing WordPress, to make WordPress available at https://mydomain.com just change in Settings->General, the Blog address (URL) to https://mydomain.com and put this index.php file in your web-root folder (it is the same folder that contains the blog folder)

    <?php
    /* Short and sweet */
    define('WP_USE_THEMES', true);
    require('./blog/wp-blog-header.php');
    ?>

    Then update your permalinks in Settings->Permalinks.

    In the event that is not what you want, look at this FAQ:
    How can I have a static front page and posts display on a page called Blog?

    Thread Starter redwoodfloors

    (@redwoodfloors)

    Thanks for the tip. In terms of my site structure, my goal is really to just get the loop displaying recent posts off of the main page and onto /blog. I want the main page to still be powered by WP as it will contain some widgets and links like <a href='<?php wordpress_link…’

    Most important, I’d like to figure out what is causing the error. I would like to make custom themes in the future, so I’d like to debug this. Is this an error this forum has dealt with before? Was there anything in my page template that was clearly written incorrectly?

    If your site is powered by WordPress and Blog is a Page that has the Blog Page Template associated with it, then don’t know why you would need:

    //load index to show blog
    load_template(TEMPLATEPATH . '/index.php');

    Thread Starter redwoodfloors

    (@redwoodfloors)

    Thanks for that last tip. I only included it as part of the instructions in the WP Documentation I linked to above. On a side note, I ended up deleting this install of WordPress, reinstalling and was able to create the custom page. That worked for me as I was starting a theme from scratch… Not going to work for someone with an existing site. Thanks for the guidance. ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom Page Template – troubleshooting’ is closed to new replies.