• Resolved creativitypro

    (@creativitypro)


    Hi all,

    Are there any plugins or tools out there that enable you to change and manage Category, Page and Post ID’s? (rather than having to hack a theme each time to match the ID’s of the WP installation)

    I would like to have consistent category, post and page id’s between a number of different wordpress installations (so that one theme fits all) 🙂

    Any suggestions most appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Instead of trying to change ID’s around (you can’t, it would be a massive pain in the arse, so don’t try), WordPress has several functions to allow you to work with categories and such by name instead of by ID.

    For example, to get the ID of a category named “General”:
    $id = get_cat_ID('General');

    Or if you need to get a page using it’s title:

    $page = get_page_by_title('Some Title')
    echo $page->ID;

    And you can always do stuff directly if you need to:

    $title = 'Some Title';
    $post_id = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title = %s", $title) )

    Use tricks like that to get the info you need to get. Or whatever, sometimes you don’t even need the ID if you use the alternative functions to get by title/slug/etc.

    Thread Starter creativitypro

    (@creativitypro)

    Thanks Otto,
    That’s a much much better idea 🙂
    Very much appreciated.

    where i need to paste this code?

    thanks
    da

    What I found the easiest is just changing the category’s slug, and sort the categories based on the slugs. You have full control over your slugs, so you can for instance start all of them with a number – for ordering purposes 🙂

    Then just add/change your template’s sidebar.php (or wherever else you want to list your catelories) to:

    <?php wp_list_categories(‘orderby=slug’); ?>.

    Perhaps with some other parameters.

    More about listing categories in WP on http://codex.wordpress.org/Template_Tags/wp_list_categories.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Category, Post and Page ID management plugin?’ is closed to new replies.