Custom theme breaks sidebar on some posts but not others
-
Post the URLs of an broken and unbroken page so people can look at the code.
It’s a draft site so was a bit reluctant to do this, particularly as I was still playing with the DIV scenario. Anywho, see these two links:
http://www.omniousmusic.com/test/downloads/ebook-market-your-own-music/ (not broken)
http://www.omniousmusic.com/test/article-submission/top-25-article-directories/ (broken)
Thanks.
The broken page is missing the closing div for “content”:
[Invalid]Markup Validation of omniousmusic.com test article-submission top-25-article-directories – W3C Markup Validator. Scroll down in the validation report to see line numbers and source code.Is that a category page? A page that uses a different template than page.php?
Both are posts. You can see that both links have the <<previous and next>> links at the bottom.
I have now added the closing div tag to close the content div on single.php. Now check the links again and you’ll see that link A is now broken (in a different way) and link B is now fixed.
Any ideas now you can see what I mean?
Without being able to see the real source, I can’t figure out where the extra div is coming from. Check your content area and widgets for extra divs. If it’s different when you’re logged in, check around the comment form area.
Thanks, that would make sense. When the comment form is switched off the page is fine. When switched on it’s broken. Well spotted.
I’ll do some digging and see if I can pinpoint it now – thanks!
Well, I’ve looked over comments.php and there’s an equal number of opening and closing
div
tags. I’ve followed it through and everything gets closed.All template files have an equal number of opening and closing
div
tags with the exception of header.php and footer.php which makes sense.Looking at the source of the broken post (when parsed in the browser) there are 71 div tag, including closing tags, suggesting one is missing and the post that’s OK has 68.
I now know what the issue is;
left_articles
isn’t being closed andleft_articles
,sidebar
andfooter
are being included within divleft
due to it but I’m not sure where this is happening.The full theme is available at http://ericulous.com/2007/01/19/wp-theme-internet-music/ for anyone who may be curious.
[sits here slowly going nuts]
I’ve commented out the
comments_template()
command from both page.php and single.php and it’s fixed the problem so the issue definitely lies within comments.php as far as I can tell. I’m thinking there’s a div being opened within a loop and then not closed in the same loop or something similar, maybe?There’s also a working demo at http://ericulous.com/demo/ which seems to be fine.
Any further help would be truly appreciated.
Compare your copy of comments.php with the same file from a fresh download of the theme.
I have already tried reuploading the original unedited theme to my blog and its still broken, yet their live demo works fine. That’s the first thing I tried π
Puzzle. I guess deactivate all plugins for a minute. And try deactivating all widgets, too.
I am having exactly the same problem.
When comments is turned on, my widget appears on the right as it should do, but if comments are switched off, I get the widget appearing under the main content.
I’ve asked about ti here:
http://wordpress.org/support/topic/widgets-move-below-main-text-when-comments-turned-off?replies=3It seems I may have found the little blighter. Adding
</div>
to line 38 seems to have fixed it π
- The topic ‘Custom theme breaks sidebar on some posts but not others’ is closed to new replies.
(@omnimusi)
13 years, 8 months ago
Hi guys,
I have a problem where on some of my posts the sidebar drops to below the content. It’s obviously down to a div that hasn’t been closed or something simple. But wherever I put it it fixes the problem as I expected but it seems to break other pages in the process…
I am using the Internet Music theme available at http://ericulous.com/2007/01/19/wp-theme-internet-music/ . I have disabled all dynamic widgets and necessary plugins and also reinstalled the theme from scratch but still get the issue. And the guy that converted the theme to WP seems to have gone quiet.
Now, just above the
get_sidebar()
andget_footer()
code in single.php of my template I added a closing div which fixed the issue. But that then made the issue appear in other pages. So I undid it. I tried the same with page.php which fixed some page but not others so I had to undo that because I use a PAGE as my home page and that broke too. Editing both also doesn’t work.So I’m thinking there may be a loop somewhere that adds a div to some pages and not others which would make sense until I saw two posts – one fixed and one broken. Both were straightforward text, no fancy div styling or anything.
Looking at the two different posts using firebug, the body tag contains
single single-post postid-xxx
, with xxx being the post id. The two posts contain the same body tag code, with the exception of the post id, yet one contains an extra div to the other, one being broken and the other being fine.I’m so lost with this I can’t figure out how to fix it without breaking other pages. Has anyone seen this issue before with other themes and know how to fix it?
EDIT: It’s probably also worth mentioning that the issue doesn’t exist if you are logged in :s