Title: emmi's Replies | WordPress.org

---

# emmi

  [  ](https://wordpress.org/support/users/emmi/)

 *   [Profile](https://wordpress.org/support/users/emmi/)
 *   [Topics Started](https://wordpress.org/support/users/emmi/topics/)
 *   [Replies Created](https://wordpress.org/support/users/emmi/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/emmi/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/emmi/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/emmi/engagements/)
 *   [Favorites](https://wordpress.org/support/users/emmi/favorites/)

 Search replies:

## Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)

 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Categories and Subcategories](https://wordpress.org/support/topic/categories-and-subcategories-2-2/)
 *  [emmi](https://wordpress.org/support/users/emmi/)
 * (@emmi)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/categories-and-subcategories-2-2/#post-771670)
 * Hi!
    Yes, you can have subcategories in the sidebar. Do you want to list the 
   subcategories for each parent category in separate lists with the name of the
   parent category as the title?
 * Then you can put some code like this in your sidebar. Change the “child_of=numbers”
   to the number of the parent category.
 *     ```
       <h2>WORK</h2>
   
       <?php wp_list_categories('title_li=0&show_count=1&child_of=1'); ?>
   
       <h2>FUN</h2>
   
       <?php wp_list_categories('title_li=0&show_count=1&child_of=2'); ?>
       ```
   
 * If you want widgets, you can try:
    [http://wordpress.org/extend/plugins/wordpress-navigation-list-plugin-navt/](http://wordpress.org/extend/plugins/wordpress-navigation-list-plugin-navt/)
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [subcategory dynamically matching parent category templates](https://wordpress.org/support/topic/subcategory-dynamically-matching-parent-category-templates/)
 *  [emmi](https://wordpress.org/support/users/emmi/)
 * (@emmi)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/subcategory-dynamically-matching-parent-category-templates/#post-694107)
 * Hi!
    I’ve also been trying and trying to solve the same thing. Then I did find
   a way to make it work. When putting this code in category.php (only this code,
   nothing else) it takes all the childcategories of category-3 to one template 
   and all childcategories of category-4 to another.
 *     ```
       <?php
       $category = $wp_query->get_queried_object();
       if ( $category->category_parent ) {
       	$cat_parent = $wpdb->get_var("SELECT name from $wpdb->terms WHERE term_id = $category->category_parent");
       }
        ?>
        <?php if ($category->category_parent == 3) {
        	include(TEMPLATEPATH . '/first_categorytemplate.php');
       }elseif ($category->category_parent == 4) {
       	include(TEMPLATEPATH . '/second_categorytemplate.php');
       	 } else {
   
        include(TEMPLATEPATH . '/categorytemplate_for_everything_else.php');
        }
        ?>
       ```
   
 * I was so happy until I tried to do the same thing on single.php and found out
   it does not seem to work on single posts.
 * Have to keep on trying I guess (each of my parent categories has about 25-35 
   subcategories so writing them down one by one just seem to much)
    When I get 
   time I’ll also have a look at the code you’ve posted johpg, and se if I can get
   it to work, or if it perhaps works better.
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [restrict access level to specific post or page](https://wordpress.org/support/topic/restrict-access-level-to-specific-post-or-page/)
 *  [emmi](https://wordpress.org/support/users/emmi/)
 * (@emmi)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/restrict-access-level-to-specific-post-or-page/#post-781852)
 * I just found another topic with a lot more information on the same subject:
    
   [http://wordpress.org/support/topic/181479?replies=31](http://wordpress.org/support/topic/181479?replies=31)
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [restrict access level to specific post or page](https://wordpress.org/support/topic/restrict-access-level-to-specific-post-or-page/)
 *  [emmi](https://wordpress.org/support/users/emmi/)
 * (@emmi)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/restrict-access-level-to-specific-post-or-page/#post-781851)
 * I just found another topic with a lot more information on the same subject:
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [restrict access level to specific post or page](https://wordpress.org/support/topic/restrict-access-level-to-specific-post-or-page/)
 *  [emmi](https://wordpress.org/support/users/emmi/)
 * (@emmi)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/restrict-access-level-to-specific-post-or-page/#post-781850)
 * This is how I do it and I don’t know if this is the best way or anything but 
   at least it works for me:
 * To limit the access to one particular page (or some pages) so that only logged
   in users can reach it, I make a new page template for that purpose and then I
   put this bit of code in the beginning of the template (right after the <?php /*
   Template Name: anything_you_want_to_call_it */ ?> ):
 * <?php if ( !is_user_logged_in() ) {
    nocache_headers(); header(“HTTP/1.1 302 
   Moved Temporarily”); header(‘Location: ‘ . get_settings(‘siteurl’) . ‘/wp-login.
   php?redirect_to=’ . urlencode($_SERVER[‘REQUEST_URI’])); header(“Status: 302 
   Moved Temporarily”); exit(); } ?>
 * (I’ve copied this code almost directly from the Angsuman’s Authenticated WordPress
   Plugin and it redirects nicely to the login-page and then, after logging in, 
   takes you back to whatever page you tried to reach. So I like that, but of course
   you can just as well decide that something else should happen to your not logged
   in visitors).
 * Then of course this page-template has to be chosen for the page or the pages 
   you want to restrict access to.
 * In the same way I also hide some parts of the content within the templates that
   I don’t want people to se if they’r not logged in. It could for example be the
   links to the pages they don’t have access to, like this:
 * <?php if ( !is_user_logged_in() ) wp_list_pages(‘exclude=4,21’ );
    else wp_list_pages();?
   >
 * Guess that if you want different access for different groups you could use something
   like the Role Manager-plugin and, for example, assign everyone in committee 1
   to the new role “committee 1” and everyone in committee 2 to the role “committee
   2”. Then create a new capability for each of the roles, lets say that you are
   naming them “access one” and “access two” .
    Then, you can make one page-template
   for each group/committee in the same way as I did in the example above except
   that you change the part of the code saying “( !is_user_logged_in() )” to “( !
   current_user_can( ‘access_one’ ) )” in the committee 1 page-template, and “( !
   current_user_can( ‘access_two’ ) )” in the committee 2 page-template.

Viewing 5 replies - 1 through 5 (of 5 total)