WordPress.org

Support

Support » How-To and Troubleshooting » category slug… how to?

category slug… how to?

  • In the category section, you can assign the slug you want, however, I haven’t gotten yet how to start wordpress using the slug instead of numerical ids. IE: in my menu I have categories listed (there are many)… how do I get the menu to list the links with the slug? I found this in the codex
    <?php echo category_description(get_category_by_slug('category-slug')->term_id); ?>

    but if that’s needed where do I put it so I get my category list in the menu to use the slug? Doesn’t that need to rewrite the htaccess file to redirect links?
    thanks
    JSC

Viewing 2 replies - 1 through 2 (of 2 total)
  • How about this that lists all categories:

    <?php
    foreach( (get_categories()) as $category) {
        echo '<p><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->slug ) . '" ' . '>' . $category->slug.'</a></p> ';
    }
    ?>

    JSC-
    Confusingly, when you select the Day and Name option under Common Settings in the WP-Admin tool under Settings > Permalinks you change the way permalinks are created for your posts it fails to mention that your category links will change from a query string with an ID passed to the /category/slug/ URLs. It’s also frustrating that if you set out looking how to change just your category URLs look, there’s nothing in the admin tool to suggest that setting is the way to make this happen.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘category slug… how to?’ is closed to new replies.
Skip to toolbar