WordPress.org

Ready to get started?Download WordPress

Forums

Display Widgets
Logic missing to handle pages with categories (2 posts)

  1. awgreenblatt
    Member
    Posted 2 years ago #

    Perhaps there is a better way of doing this, but I am using the "Map Categories to Pages" plugin to assign categories to various static pages. I'm then trying to use the "Display Widgets" plugin to decide which widgets show up with which pages. Unfortunately, the logic seems to be missing in the "Display Widgets" plugin to handle the check for whether static pages have a category.

    In function show_dw_widget($instance), just before the check for:

    }else if (is_404()){

    I've added the following code locally:

    }else if (is_page()){
    	$show = false;
            $cats = get_the_category();
            foreach($cats as $cat){
                if ($show) continue;
                $cat_id = dw_get_lang_id($cat->cat_ID, 'category');
                if (isset($instance['cat-'. $cat_id]))
                    $show = $instance['cat-'. $cat_id];
            }

    This seems to work great. It would be super if we could get this (or something like it) into the main trunk.

    http://wordpress.org/extend/plugins/display-widgets/

  2. awgreenblatt
    Member
    Posted 1 year ago #

    Hi there,

    I find this plugin extremely useful, but unless I'm missing something, it only works for posts, not pages. I put this request in 7 months ago and there have been 2 releases since. Is there a reason to not put in this support for pages?

    Thanks very much.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic