• Resolved Leontien

    (@leontien)


    I have several categories on my left bar. I need to have different widgets on each category. Once you click on a category, it will only show the widgets that I have placed on that particular category. I have tried several plugins, nothing worked, I have tried to change things in php files, nothing worked, please help.

    My site is http://moneyinpoliticsohio.org/
    You will now see that all the widgets are the same on the home page and on each category.

Viewing 14 replies - 1 through 14 (of 14 total)
  • Hello Leontien… Just to let you know, your website returned a Malware Detected warning.

    Without looking at the site, typically these settings are in the sidebar.php and functions.php file. The sidebar calls the widgets and should be the file that tells the widgets to turn on/off for pages, posts, categories, etc… The functions file defines the sidebars, which displays them in the admin.

    Some pages that may help:
    http://codex.wordpress.org/Customizing_Your_Sidebar#New_way_of_adding_sidebars
    http://codex.wordpress.org/Function_Reference/register_sidebars

    Thread Starter Leontien

    (@leontien)

    Thanks! The problem is that I can’t find the functions or sidebar php in my FTP. Can you help me find it?

    That site is coming up with a clean scan.

    I can’t find the functions or sidebar php in my FTP

    Try looking in your current theme’s folder in wp-content/themes.

    Thread Starter Leontien

    (@leontien)

    Great, I found it, when I add

    <?php if ( function_exists ('register_sidebar')) {
        register_sidebar ('custom');
    } ?>

    [Please post code or markup snippets between backticks or use the code button.]

    to my functions.php (at the bottom), I can’t even get to my widgets anymore, there is an error message. It would be great if someone could help me put a certain code somewhere. i really appreciate the help.

    Try:

    if ( function_exists ('register_sidebar')) {
        register_sidebar ('custom');
    }
    Thread Starter Leontien

    (@leontien)

    I put in;

    if ( function_exists ('register_sidebar')) {
        register_sidebar ('custom');
    }

    [Please post code or markup snippets between backticks or use the code button.]

    in the functions.php (or should I have put it in the widgets.php?) and again error message. Can I just put it on the bottom?

    Just make sure it goes before any ending ?> tag in functions.php.

    Thread Starter Leontien

    (@leontien)

    Yes, I added that ?> after it. Okay, it worked, I can see my widget page (the back end)… But I still don’t see how I can use it, I mean, I was hoping that in the widget (for example a text widget) I would be able to scroll down and it would tell me where I want this specific text to go, under which category.

    Thread Starter Leontien

    (@leontien)

    My next step would possibly be:

    ‘custom’ would mean you have to create a custom sidebar-file under the name sidebar-custom.php. Sidebars get indexed. Your default sidebar (sidebar.php) gets indexed as 1. Every succeeding one will have an index higher than 1. You will see your sidebars now listed in ‘Appearance’ -> ‘Widgets’.

    I don’t understand this, could anyone explain in layman terms? THANKS!

    No – that won’t work with out quite a lot of theme editing/customisation. Have a look at http://wordpress.org/extend/plugins/widget-logic/ instead.

    Thread Starter Leontien

    (@leontien)

    I have looked at this plugin before. When I activate it though, my site goes into error. This is what is says:

    Parse error: syntax error, unexpected ‘:’ in /var/www/vhtdocs/userweb51311/html/wp-content/plugins/widget-logic/widget_logic.php(169) : eval()’d code on line 1 Parse error: syntax error, unexpected ‘:’ in /var/www/vhtdocs/userweb51311/html/wp-content/plugins/widget-logic/widget_logic.php(169) : eval()’d code on line 1

    Thread Starter Leontien

    (@leontien)

    Will this help:

    if(function_exists(‘register_sidebar’)) {
    foreach((array)(get_categories()) as $category) {
    register_sidebar(array(
    ‘name’ => ‘Categorie : ‘ .$category->cat_name,
    ‘before_widget’ => ‘<div id=”%1$s” class=”%2$s widget”>’,
    ‘after_widget’ => ‘</div>’,
    ‘before_title’ => ‘<h3 class=”widget-title”>’,
    ‘after_title’ => ‘</h3>’, ));
    }

    foreach((array)(get_pages()) as $page) {
    register_sidebar(array(
    ‘name’ => ‘Page : ‘ .$page->post_name,
    ‘before_widget’ => ‘<div id=”%1$s” class=”%2$s widget”>’,
    ‘after_widget’ => ‘</div>’,
    ‘before_title’ => ‘<h3 class=”widget-title”>’,
    ‘after_title’ => ‘</h3>’, ));
    }
    }

    I added this to functions.php but I can’t seem to find it back on the back end anywhere?

    What version of WordPress are you using?

    Thread Starter Leontien

    (@leontien)

    I just found the answer to my question. It’s a plugin called “Conditional Widgets”.
    Thanks!

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Separate widgets on every category’ is closed to new replies.