• Resolved dan.tee

    (@dantee)


    Hi!

    I’ve nearly completed my first WP site (www.surgicalscousers.co.uk – not uploaded yet…) using a modified Twenty Ten theme. The modifications are either in the style.css file, or in the div structure for each page.

    The problem I have is that all my static pages work just fine and display as I intended them to. The design is a dead simple two-column affair – I replaced the Twenty Ten floated div structure with a slightly more complex nested floating div structure with background gifs to show the columns. This works fine on all pages designated as static, including the home page. But the blog page… well, we’re down to the non-matching column height problem. The sidebar and content columns just don’t match like they do on the other pages.

    I’m working this in Dreamweaver, and have used the find and replace feature to replace all mentions of the twenty Ten original structure with my own (all static pages working fine) but I can’t work out which php doc is constructing my blog page to work out the problem. That’s really the question: when you specify a page as the blog, which php doc controls it (I thought it was page.php)

    I have enough CSS experience to fix it if I knew where to find the problem! Thanks for reading, and I hope someone can point me in the right direction. I will be uploading the site at some point today, so if it’s essential for a guru to see the site to understand the problem, let me know and I’ll get on with the upload!

    Thanks,

    Dan

Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter dan.tee

    (@dantee)

    I’ve now uploaded the offending website to https://www.surgicalscousers.co.uk.

    I’m pretty sure index.php always displays your posts

    Taken From https://codex.www.ads-software.com/Pages

    What Template is used to Display a Particular Page?
    WordPress will look for several template files in your active Theme. The first one it finds will be used to display any given Page. WordPress will look for files in the following order:

      1. The Page’s selected “Page Template”
      2. page.php
      3. index.php

    Check to see if you selected a template file by mistake.

    Another option might be the large text pushing the sidebar out of div forcing it down. Or maybe how the image is displayed. Try bring your content width down maybe by a few pixels also. Try 5.

    You could create a Template file just for you blog to correct the issue also, as it’s just that page that is offending.

    Creating Your Own Page Templates
    The files defining each Page Template are found in your Themes directory. To create a new Custom Page Template for a Page you must create a file. Let’s call our first Page Template for our Page snarfer.php. At the top of the snarfer.php file, put the following:

    <?php
    /*
    Template Name: Snarfer
    */
    ?>

    The above code defines this snarfer.php file as the “Snarfer” Template. Naturally, “Snarfer” may be replaced with most any text to change the name of the Page Template. This Template Name will appear in the Theme Editor as the link to edit this file.

    The file may be named almost anything with a .php extension (see reserved Theme filenames for filenames you should not use; these are special file names WordPress reserves for specific purposes).

    What follows the above five lines of code is up to you. The rest of the code you write will control how Pages that use the Snarfer Page Template will display. See Template Tags for a description of the various WordPress Template functions you can use for this purpose. You may find it more convenient to copy some other Template (perhaps page.php or index.php) to snarfer.php and then add the above five lines of code to the beginning of the file. That way, you will only have to alter the HTML and PHP code, instead of creating it all from scratch. Examples are shown below. Once you have created the Page Template and placed it in your Theme’s directory, it will be available as a choice when you create or edit a Page. (Note: when creating or editing a Page, the Page Template option does not appear unless there is at least one template defined in the above manner.)

    Thread Starter dan.tee

    (@dantee)

    Thanks for your input folks, particularly @killswitch. I’ve now made the blog page use the page.php template by giving page.php a template name as copied from the text above (yes, I’ve even used ‘snarfer’!) However, the problem persisted, suggesting therefore that something was wrong with page.php. So… I made a copy of page.php, stripped out the php where it was calling for the structural elements (header, footer, sidebar), and pasted back in the html (copied from the PHP docs) for those items. View it locally on my browser – works fine. Upload it to the top level of the site (www.surgicalscousers.co.uk/page.htm) it works fine. But the same file, with a new doc name and the template info added, and loaded to the site, and the blog page made to use it as the template… displays the same problem. So far as I can tell, there’s nothing wrong with the code – WP just won’t show it right, and only on that page!

    Help!!

    Thread Starter dan.tee

    (@dantee)

    So I’ve just tried making one of the other pages use the new page template that the blog page is using… and it works just fine. Something about the fact that the blog page has The Loop on perhaps or just blog posts in general is breaking the ability of the underlying CSS to make the ‘columns’ match each other in height. I think I’m going to cry now.

    Hmmm.

    Quick thing to try. I know I had this problem with phpBB. with creating a page template to use the forum code as a website backend.

    Open you page.php in Notepad ++. Encode the file to UTF-8. Save and re-upload (hard). Not by the built in wordpress editor.

    Would you mind posting your page.php? I know you worked hard on re-coding the theme, and it’s clearly visable of your efforts, and understand your fustration at this point. I’m working on a theme for a client at work on my laptop, as the computers at work won’t allow me to run xampp :(.

    **** AFTERTHOUGHT ****
    Also ensure you are not missing any closing tags in both your page.php or your sidebar.php

    I had to, once, throw my header, page, sidebar, footer into ONE file, save as html and checked the tags. I was missing a closing </div> in my sidebar. Just something for you to look into.

    **** END AFTERTHOUGHT ****

    Thread Starter dan.tee

    (@dantee)

    now it turns out that the blog page is refusing to use the template I tell it to. I’ve added a text snippet (Literally, straight into the HTML) to all of index, page, sidebar of ‘test of theory’. It appears on ALL sections and pages of the site, indicating that they are all using the same template, yet when the Blog page loads, the site structure breaks. No matter what I set as the template page for Blog in the admin, it’s defaulting to using the defaults. Which work fine on all the other pages.

    Thread Starter dan.tee

    (@dantee)

    Hi killswitch – only just read your post. Will try what you suggest with the UTF-8 and will check again for dodgy tags. I’m also working in Dreamweaver on the Mac by the way, so I don’t have access to Notepad. Here’s the page.php:

    <?php
    /*
    Template Name: Snarfer
    */
    ?><?php
    /**
     * The template for displaying all pages.
     *
     * This is the template that displays all pages by default.
     * Please note that this is the WordPress construct of pages
     * and that other 'pages' on your WordPress site will use a
     * different template.
     *
     * @package WordPress
     * @subpackage Twenty_Ten
     * @since Twenty Ten 1.0
     */
    
    get_header(); ?>
    
    		<div class="contentContainer">
        <div class="leftContentContainer">
          <div class="leftContent">test of theory
    
    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    
    				<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    					<?php if ( is_front_page() ) { ?>
    						<h1 class="entry-title"><?php the_title(); ?></h1>
    					<?php } else { ?>
    						<h1 class="entry-title"><?php the_title(); ?></h1>
    					<?php } ?>
    
    					<div class="entry-content">
    						<?php the_content(); ?>
    						<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
    						<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
    					</div><!-- .entry-content -->
    				</div><!-- #post-## -->
    
    				<?php comments_template( '', true ); ?>
    
    <?php endwhile; ?>
    
     </div>
          <!-- end of leftContent -->
        </div>
        <!-- end of leftContentContainer -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Thread Starter dan.tee

    (@dantee)

    OK, my mistake here: Blog uses index.php to construct itself. We might be getting somewhere now:

    <?php get_header(); ?>
      <div class="contentContainer">
        <div class="leftContentContainer">
          <div class="leftContent">test of theory
          	<?php
    			/* Run the loop to output the posts.
    			 * If you want to overload this in a child theme then include a file
    			 * called loop-index.php and that will be used instead.
    			 */
    			 get_template_part( 'loop', 'index' );
    			?>
              </div>
              <!-- end of entry -->
            </div>
            <!-- end of post -->
          </div>
          <!-- end of leftContent -->
        </div>
        <!-- end of leftContentContainer -->
        <?php get_sidebar(); ?>
        <?php get_footer(); ?>

    Thread Starter dan.tee

    (@dantee)

    ah ha! The reconstruction of index.php without the php includes for footer, header and sidebar has just worked a treat. So now I will try replacing the includes one at a time, and we’ll see where we get to. The light is on at the end of the tunnel!

    Thread Starter dan.tee

    (@dantee)

    SOLVED! Thanks kill-switch413! I don’t think I’d have got that far without your help. Turns out that sidebar.php had secondary widget area outside my designated side bar divs. Not a problem on all the other pages – they weren’t calling secondary widgets. But Blog apparently must be.

    But it’s all fixed now, praise God! Thank you sir, very much indeed.

    Glad to help.

    I’m new to this also, I just discovered the greatness of WordPress. But I’ve gotten a good handle of the logic behind it. As %100 of my job is figured/troubleshooting stuff just like this.

    Now, get rid of those comments of your site being broken and start adding some content. ??

    Oh and I’m no where close to being a Sir. I’m a youngin. Big 25.

    Thread Starter dan.tee

    (@dantee)

    Thankfully adding the content is the client’s job! At least I can show him a working site now. ‘Sir’ was merely a recognition of greater talent than mine – I much prefer drawing things than code!

    Thanks again.

    Understood.

    GL in the next project. Nice work on this one. I like the layout.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘what PHP doc does Twenty Ten use to make a static page into a blog?’ is closed to new replies.