WordPress.org

Ready to get started?Download WordPress

Forums

Posting with multi categories divided by templates: how to hide them? (1 post)

  1. Elan42.com
    Member
    Posted 6 years ago #

    Hi...

    I'm doing an entire website with wordpress.

    My intention is to divide the blog part, by the news part, by the work and photography part.

    To do that, I used two templates, one that load "everything but news", and the other that load "only news" categories.

    The problem is that now I want to do more templates and it will be hard to keep updated the code cause I have also to produce custom sidebars hiding categories I'm not inside, for example if i'm inside the news part I don't want the visitor to see the blog categories.

    So I'm asking you if that is a "not-common" problem, and if there is a better solution for that.

    Actually, to know where the user is, I setted up a function called in the index.php file that saves in:
    $_SESSION['nokao_menu']
    the position where the user is.

    So I can easily produce a custom sidebar for every "part" of the website I am.
    I have to look only one variable instead of dozens of...
    I have also to "leave pressed" the section where I am in the website so that is useful to do that.

    I also putted a:
    $_SESSION['nokao_menu']='News'
    In the template that loads only News category and a ='Blog' in the template that loads the Blog categories.

    The actual code of the function is that:

    function nokao_startup(){
      if(!$_SESSION['nokao_menu']) {
       if ((is_single()) or (is_category())){
        if(!in_category(13)){ $_SESSION['nokao_menu']='Blog'; }
        else $_SESSION['nokao_menu']='Home';
       }
       else if (is_page()){
        global $post;
        if (($post->ID)==59) $_SESSION['nokao_menu']='Home';
        if ($post->post_parent > 0) {
               $parent_page=nokao_get_top_parent_page();
               if ($parent_page==50) $_SESSION['nokao_menu']='Work';
           elseif ($parent_page==45) $_SESSION['nokao_menu']='Photography';
           elseif ($parent_page==60) $_SESSION['nokao_menu']='Blog';
           elseif ($parent_page==17) $_SESSION['nokao_menu']='Feel';
           elseif ($parent_page==55) $_SESSION['nokao_menu']='Contact';
        }
       }
      }
    }

    Concluding... my question is if I'm doing right or if there are bettere ways to get this done.

    Consider that I have to reference categories with their id actually and it's not a good thing, IMHO.

    The website is there if you need to understand the structure:
    http://www.nokao.com

Topic Closed

This topic has been closed to new replies.

About this Topic