WordPress.org

Ready to get started?Download WordPress

Forums

category slug... how to? (3 posts)

  1. jami1955
    Member
    Posted 5 years ago #

    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

  2. MichaelH
    Member
    Posted 5 years ago #

    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> ';
    }
    ?>
  3. mwolstat
    Member
    Posted 5 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic