WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Advanced Access Manager] Parent categories without posts are not showin (7 posts)

  1. ElwoodP
    Member
    Posted 2 years ago #

    I want to restrict editing access to a particular category but the category is not listed (under Posts and Pages tab).

    http://dl.dropbox.com/u/3454522/Cats.png
    http://dl.dropbox.com/u/3454522/Missing_Cat.png
    (Accordians and all its child categories are missing)

  2. WP AAM
    Member
    Posted 2 years ago #

    Hi ElwoodP,
    This is a standard WordPress behavior. You should have atleast one post to list a category. I'm using functions that WordPress core offers.

    Regards,
    Vasyl

  3. ElwoodP
    Member
    Posted 2 years ago #

    Thanks Vasyl. I'm very new to WordPress so might get this wrong! - If you are using something like "get_terms" function can you not just set "hide_empty" argument to 0?

    Jus doesn't seem to make sense to exclude categories with no posts in this instance (especially when they could have children with posts).

    Great plugin by the way. I tried a few similar plugins but found Access Manager by far the best solution for me. Seems powerful yet easy to use. Perfect combination!

  4. ElwoodP
    Member
    Posted 2 years ago #

    This seems to work...

    private function build_categories($post_type, $taxonomy = FALSE, $parent = 0) {
    
            $tree = array();
    
            if ($parent) {
                //$taxonomy = $this->get_taxonomy_get_term($parent);
                //firstly render the list of sub categories
                $cat_list = get_terms($taxonomy, array('get' => 'all', 'parent' => $parent, 'hide_empty' => 0));
                if (is_array($cat_list)) {
                    foreach ($cat_list as $category) {
                        $tree[] = $this->build_category($category);
                    }
                }
            } else {
                $taxonomies = get_object_taxonomies($post_type);
                foreach ($taxonomies as $taxonomy) {
                    if (is_taxonomy_hierarchical($taxonomy)) {
                        $term_list = get_terms($taxonomy, array('parent' => $parent, 'hide_empty' => 0));
                        if (is_array($term_list)) {
                            foreach ($term_list as $term) {
                                $tree[] = $this->build_category($term);
                            }
                        }
                    }
                }
            }
  5. WP AAM
    Member
    Posted 2 years ago #

    ElwoodP,
    Thanks for code. Looks like I didn't pay much attention on that issue. I'll check the solution and include it in next release.
    Regards,
    Vasyl

  6. jdm
    Member
    Posted 2 years ago #

    This is a really important feature for me and has been the main difficulty I've had with your plugin, which otherwise has a lot of great features! Thanks for offering it to the community and I'd really appreciate this enhancement as soon as you include it!

  7. WP AAM
    Member
    Posted 2 years ago #

    Hi jdm,
    I implemented this fix in release 1.6.5. Now it is under testing and if everything will be ok, it'll come out of oven on Sunday 6th.

    Regards,
    Vasyl

Topic Closed

This topic has been closed to new replies.

About this Topic