WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to show only category name? (5 posts)

  1. duck1
    Member
    Posted 7 years ago #

    Hello,
    I want to display only names of ALL categories. No html tags like

    "li" or "a". How can I show only the names?
    I have no idea :(

    Thanks

  2. MichaelH
    Member
    Posted 7 years ago #

    See if the template tag, wp_list_categories will produce satisfactory output for you.

    If that won't work for you then you'll need a special query so take a look at Function_Reference/wpdb_Class.

  3. pramodd
    Member
    Posted 7 years ago #

    Open category-template.php [its a file that comes with WP and is located in the wp-includes directory] in your favorite editor. Remove references to li & a and then upload file to wp-includes directory on your web server.

  4. MichaelH
    Member
    Posted 7 years ago #

    This echos all categories considered post categories:

    <?php
    $mycategories = $wpdb->get_col("SELECT cat_name FROM $wpdb->categories WHERE category_count > 0 ORDER BY cat_name");
       if ( ! empty($mycategories) ) {
          foreach ( $mycategories as $mycats ) {
            echo $mycats;
          }
       }
    ?>
  5. duck1
    Member
    Posted 7 years ago #

    Thanks. :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.