Results 1 to 4 of 4

Thread: Problem displaying custom sidebar in Wordpress

  1. #1
    Join Date
    Jul 2010

    Problem displaying custom sidebar in Wordpress


    First time poster so apologies if i've asked this in the wrong sub-forum.

    My boss has asked me to mock up the existing site into a Wordpress-controlled CMS. It's gone pretty well so far but I've hit a snag with one particular function and while I'm decent enough at tinkering with PHP, I can't figure this one out.

    As you probably know, Wordpress by default displays individual blog posts on the home page but you can set a static page and specify an alternative (created) page in which to place blog posts (Settings>Reading - done!) - i'm using this function as a news feed and I've created a 'home' page as the static landing page and a 'news' page to store the posts.

    For each navigation category & it's child pages i'm using a customised sidebar plugin (Sidebar Generator) to display certain widgets related to the content on the page and the 'News' category should be no different. However, while the custom sidebar displays on all other pages, I can't get it to work and display on the 'news' page, although it does so on individual entries within the 'news' page. The same also happens when WP generates the monthly post archive where there is no sidebar displayed.

    I've pored through the code umpteen times, tried custom templates and all manner of workarounds and made sure that the sidebar call <? get_sidebar(); ?> is present in the relevant page templates but i can't get this to display properly. Its bloody annoying as it works fine everywhere else..

    Any help appreciated, before i go bald from pulling my hair out! The Wordpress.org forum is pretty much useless.. I've asked there for help, but getting no responses.

  2. #2
    Join Date
    Jul 2010
    Problem is replicated on a WP2.8.4 install with basic theme, making me think the plugin can't handle the news feed through a static page...

  3. #3
    Join Date
    Jun 2005
    Fullerton, CA USA
    Let me see if I understand your situation:

    1 - The 'news' page content is generated from WP posts.
    2 - Other pages use statically defined content.
    3 - The sidebar data is generated based on the content of the page on which it is displayed.
    4 - The sidebar is unable to display any content relevent to the 'news' content.

    If all that is true, then your problem is probably this:

    1 - The 'news' page content is created by the WP "loop".
    2 - By the time the sidebar is created, the "loop" has been ended, therefore there's no context in which to reference the data in 'news'. You are now outside the "loop".

  4. #4
    Join Date
    Jul 2010
    Hi mate,

    Thanks for the reply. I've tracked down the problem - I think!

    There is a call in the plugin code (not the page code, which is where I've been looking!) to check whether the served page is a single page and to only show the sidebar if the call returned 'true'. Because the 'news' page content isn't a single page - even though it feeds through a static page - it doesn't trigger the correct response to display the sidebar.

    I've added an extra conditional statement to the plugin code and it seems to be working.

    Thanks for your suggestion though!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center