Support » Requests and Feedback » Relate Categories to Pages

  • Hi I am new to wordpress and I have been trying to relate categories to pages. Through hours of searching I have not found a way to make this happen, so not even sure if it is possible. Any help would be appreciated.
    Problem In Detail
    I have a page called Sectors and within Sectors I have sub-pages called Education, Healthcare, Business and Public each with their own heading which I ma changing using a custom variable. I then have in the side bar the categories. The categories are Catering, Laundry, Grounds Keeping etc… What I am trying to do is if somebody clicks on a page (use Education for example), all the categories connected to the education page will show up in the sidebar so if there is a post written in the catering category which is linked to Education when clicked that will then show under the Education header page, but there could also be a post written under catering but connected to Healthcare, so that would not show in Education but on the Healthcare page.

    I hope this makes sense if you need more info let me know.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Connecting categories and pages can be tenuous at best. Why not just use categories to control all that. Make Education the parent category of Catering etc.

    Then you can use variations of the template tag, wp_list_categories(), to present links to those categories.

    But will add this plugin reference to consider:

    Thanks for your reply I manged to accomplish what I wanted using the page2cat plugin and altering the code in the sidebar.php. Except now it has brought me to another problem – when I click on the link on the sidebar it directs me to the page and posts that I want except the sidebar is now empty. Here is the code which I have used in the sidebar.php.

    		if (get_post_meta($post->ID,'categorynumber', true)) {
            $catid = get_post_meta($post->ID,'categorynumber', true);
    		wp_list_categories("child_of=" .$catid . "&title_li=");

    but now I want to tell it that if it is on a page which is a child category still display the categories of the parent.
    I tried using at the end of the above code

    else {
    			if (in_category ('16,10,5,18'))
    			 wp_list_categories ('parent_of=' .$catid . "&title_li=" );

    but does not work,
    I hope that this makes sense
    if not let me know I will explain in more detail

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Relate Categories to Pages’ is closed to new replies.