• Hey. Let’s cut straight to the chase.

    I need to have a specific sidebar appear on a specific page throughout my site. So for example, the page titled Games will have the sidebar titled Games appear on it.

    This is the code in my functions.php

    [code moderated per forum rule - please use the pastebin]

    As you can see I have set them up and they appear in my widgets area in the admin page.

    My problem lies with calling the sidebar to the correct page.

    I don't want to have to use page templates as I want to keep the site as fluid as possible. My idea would be to use an echo for post_name. Here is what I have so far in my sidebar.php

    <?php if (is_home()) { ?>
    
    	<?php dynamic_sidebar('home'); ?>
    
    <?php } else { ?>
    
    	<?php dynamic_sidebar('<?php echo $post->post_name; ?>'); ?>
    
    <?php } ?>

    I know this will not work as it is calling php from within a php statement.

    Is there anyway for this theory to work? If not could somebody please give me a complete low down on how best to have in total 6 sidebars. 1 for the index and then 1 for each page I have created.

    Thank you in advance!

    -Pete x

  • The topic ‘Dynamic Sidebar & Conditions’ is closed to new replies.