Forums

Intended sidebar not appearing (2 posts)

  1. kennethjaysone
    Member
    Posted 1 month ago #

    I've got a page template called individual_companies.php which is a child page of companies.php

    Companies.php includes sidebar.php for it's sidebar content.

    I want the individual_companies.php to have a different sidebar. So this is what i did:

    I took individual_companies.php and replaced this line of code:

    <?php get_sidebar(); ?>

    with this:

    <?php
         $custom_sidebar = get_post_meta($post->ID, 'sidebar', true);
         get_sidebar($custom_sidebar);
    ?>

    Are there any considerations i have to make to include a different sidebar. The code i pasted above is within the loop.

    When i use the regular get_sidebar, it works normally by including the sidebar.php

    The custom field name i added on the page (individual_companies.php page) is sidebar and the value is companies_sidebar.

    Have a look here

    the filename for the sidebar is companies_sidebar.php

    Any help is greatly appreciated..Thanks alot

    Jaysone

  2. pboosten
    Member
    Posted 1 month ago #

    have you tried putting the $custom_sidebar variable between quotes?

    get_sidebar('$custom_sidebar');

    Peter

Reply

You must log in to post.

About this Topic