emmi
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Categories and SubcategoriesHi!
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:
https://www.ads-software.com/extend/plugins/wordpress-navigation-list-plugin-navt/Forum: Fixing WordPress
In reply to: subcategory dynamically matching parent category templatesHi!
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
In reply to: restrict access level to specific post or pageI just found another topic with a lot more information on the same subject:
https://www.ads-software.com/support/topic/181479?replies=31Forum: Fixing WordPress
In reply to: restrict access level to specific post or pageForum: Fixing WordPress
In reply to: restrict access level to specific post or pageThis 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.