WordPress.org

Ready to get started?Download WordPress

Forums

How to change page category? (10 posts)

  1. elyn
    Member
    Posted 8 years ago #

    I noticed that all pages created would be under default category. Does anybody know how to change the categories of pages? Thanks.

  2. moshu
    Member
    Posted 8 years ago #

    Pages practically do NOT have categories. Being assigned to the default category is just an "internal technical" thing for WP. Try to forget about it :)

  3. elyn
    Member
    Posted 8 years ago #

    Then how to delete the display of the default category that pages blogged in?

  4. moshu
    Member
    Posted 8 years ago #

    Delete the_category tag from your Page template (page.php)

  5. elyn
    Member
    Posted 8 years ago #

    Still nothing happened...

  6. elyn
    Member
    Posted 8 years ago #

    There is no page.php in my theme template. And to delete this file under the default theme of WP results in nothing. Then I saved index.php of my theme as page.php, delete "<?php _e("Bloged in"); ?> <?php the_category(',') ?>". In that case, page won't display category anymore.

    Moshu, thanks. I didn't catch you until yesterday.

  7. htheriault
    Member
    Posted 8 years ago #

    This has been bugging me for a while so I sat down and after about an hour of looking around I found where it's being called from. My solution assumes a bit of knowledge up front as it involves editing the database, either by hand or through phpmyadmin.

    There is a table in the wordpress database that marries the post_id with the category_id, called wp_post2cat. This is where the change needs to be made.

    First step is to generate a list of your categories and then match it against your page_id. Replace specific post information from my example with your own.

    mysql> select * from wp_categories; (will generate the list)

    mysql> select * from wp_post2cat where post_id = "1104";
    +--------+---------+-------------+
    | rel_id | post_id | category_id |
    +--------+---------+-------------+
    | 147 | 1104 | 1 |
    +--------+---------+-------------+
    1 row in set (0.01 sec)

    Now that you've made sure it's there and what the id is:

    mysql> UPDATE wp_post2cat
    -> SET category_id = '5'
    -> WHERE post_id = '1104';
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1 Changed: 1 Warnings: 0

    And that's it. You've just changed the category.

  8. e7
    Member
    Posted 8 years ago #

    Well this is neat, so pages do have categories.

    It would be best if the wp team added a selection option inside the main admin menu to allow changing of page categories.

    I don't think categories for pages are bad, I just wish I could change them w/o having to do what htheriault described...

  9. moshu
    Member
    Posted 8 years ago #

    It wouldn't make any difference. You can change whatever in the database but all the Pages you are going to write after - still would be in the default category. If you change your default category: from that moment on all the new Pages will belong to that new default.

  10. abelcheung
    Member
    Posted 7 years ago #

    I've just cooked it up in several minutes after reading this discussion, available in:
    http://me.abelcheung.org/devel/wordpress-page-categories-assignation/

    However, it doesn't mean there is any visible change. Just keep blogger categorize their pages more easily, nothing more. To present pages in a categorized way needs more coding. I believe some plugin has already done that.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.