0
votes

I'm tuning up a website made with Wordpress and I'm facing a small inconvenient:

I want to use a custom template for the posts in a specific category, so I have a single-4.php file that gets me a custom php file for any post in cat.id 4. That works great, now for the problem...

PROBLEM --> I want to display a custom sidebar as well, so at the end of the single-4.php I add:

<?php get_sidebar( $evento ); ?>

As instructed in the Wordpress Codex, expecting to get my sidebar-evento.php file used istead of the default sidebar.php. But it doesn't work, instead it will just use the default behaviour instead. I have also tried "'single-evento'" instead. I know that the code line is being used because if I remove it, the sidebar area breaks ( dissapears and the page breaks).

My suspicion is that the Custom Sidebars plug-in is catching up right after I call for any sidebar and regardless of which one I'm requesting, it gets replaced. But it doesn't make much sense really. Because as you can see in my sidebar-evento.php:

<div id="right">
<h3>LINE TO CHECK IF SIDEBAR-EVENTO.PHP IS SHOWN</h3>
<?php if ( ! dynamic_sidebar( 'sidebar-1' ) ) : ?> 
    <?php endif; // end sidebar widget area ?>
<?php if ( ! dynamic_sidebar( 'sidebar-3' ) ) : ?>             
    <?php endif; // end sidebar widget area ?>
    </div></div>

Both things should happen: A) I get my custom text, then B) I get the other custom thingies as determined by the plug-in.

I hope I've been clear about what my problem is. Please bear in mind for your response that I have no PHP knowledge, I only do HTML and this is a sort of -charity- project, so I try to learn as I go. Meaning: step-by-step might be necessary! heh. Sorry!

Thank you very much in advance.

1

1 Answers

1
votes

Try:

<?php get_sidebar( 'evento' ); ?>

This should pull in sidebar-evento.php