WordPress.org

Ready to get started?Download WordPress

Forums

Customizing Templates for pages (11 posts)

  1. mkuehlhorn
    Member
    Posted 4 years ago #

    I am interested in created a different look for my pages from my blog. I have the look I want for my pages, however, I am seeking something new for the posts.

    Can I use templates to change the widgets in my sidebar so I have different widgets and links on my posts than the rest of my pages?

    I understand that I must alter the look to affect the posts and then use template to create new looks for each additional page--is this a correct assumption?

    Thanks for the assistance.

  2. s_ha_dum
    Member
    Posted 4 years ago #

    Can I use templates to change the widgets in my sidebar so I have different widgets and links on my posts than the rest of my pages?

    Yes. You can register as many sidebars as you want and place them wherever you want. For example:

    /// in your theme's functions.php
      register_sidebar(
        array(
          'name' => 'PostSidebar',
          'before_widget' => '<li id="%1$s" class="widget %2$s">',
          'after_widget' => '</li>',
          'before_title' => '',
          'after_title' => '',
        )
      );
      register_sidebar(
        array(
          'name' => 'PageSidebar',
          'before_widget' => '<li id="%1$s" class="widget %2$s">',
          'after_widget' => '</li>',
          'before_title' => '',
          'after_title' => '',
        )
      );

    Then:

    /// in your header.php, footer.php, or possibly elsewhere
    /// its hard to say for sure without knowing what theme you are using
    if (function_exists('dynamic_sidebar')) {
       if (is_page()) {
           dynamic_sidebar('PageSidebar');
       } else {
           dynamic_sidebar('PostSidebar');
       }
    }

    Assuming I didn't screw up the markup you should get two sidebars, one that shows up on 'Post' pages and one on 'Page' pages. Also, that is a pretty simplified example. I'd add some error checking in a couple of places and, most likely, you'll need to edit the (html) markup to fit it into your theme.

  3. mkuehlhorn
    Member
    Posted 4 years ago #

    Thank you! I will play around with this.

  4. mkuehlhorn
    Member
    Posted 4 years ago #

    I am using the Mondo_Zen_Theme and I believe I am placing the call for the two sidebars in the sidebar.php--though I cannot seem to get the language correct.

    Once I do get this correct do I then have the options within wordpress's editing tools to adjust the widgets, etc. for each sidebar?

  5. s_ha_dum
    Member
    Posted 4 years ago #

    Once you get the sidebars registered you can drag widgets to them from the widgets panel at wp-admin->Appearance->Widgets.

    I'll double check my code tomorrow. I may have messed something up.

  6. mkuehlhorn
    Member
    Posted 4 years ago #

    I have my two sidebars registered and the way I want the, for now.

    I am having difficulty finding the right place to identify when to pull the postsidebar.php and when to pull the pagesidebar.php.

    How do I identify which template to place this in?

  7. s_ha_dum
    Member
    Posted 4 years ago #

    You should probably already have a call to dynamic_sidebar() somewhere. You want to find that and either replace it or add the second block of code I gave you either above or below it.

  8. mkuehlhorn
    Member
    Posted 4 years ago #

    Thank you.

    I found this in my sidebar.php

    <?php /* Widgetized sidebar, if you have the plugin installed. */
    if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>

    I cannot find this type of call in my header or footer. I am not sure where else to look.

    Other pages call to the sidebar and currently they are all picking up my postsidebar sheet.

    What am I missing?

    I appreciate your help.

  9. s_ha_dum
    Member
    Posted 4 years ago #

    You need to replace that code you found with the code I gave you:

    if (function_exists('dynamic_sidebar')) {
       if (is_page()) {
           dynamic_sidebar('PageSidebar');
       } else {
           dynamic_sidebar('PostSidebar');
       }
    }

    Have you done that and it still doesn't work?

  10. mkuehlhorn
    Member
    Posted 4 years ago #

    Yes, I have done that and I get this error:

    Parse error: syntax error, unexpected T_ENDIF in /home/kuehlhor/public_html/lifeskoolz.com/lifeskills/wp-content/themes/mondo-zen-theme/sidebar.php on line 48

    I appreciate your help and looking for ideas?

  11. s_ha_dum
    Member
    Posted 4 years ago #

    Paste your sidebar.php into the pastebin. You've broken something-- missing curly brace, that kind of thing.

Topic Closed

This topic has been closed to new replies.

About this Topic