Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter grievance

    (@grievance)

    Alright well it seems I figured this out on my own.

    To display all categories applied to your post, use the following code:

    `// Used for pulling related categories to each post (multiple categories)
    $posts_columns = array();
    $posts_columns[‘categories’] = __(‘Categories’);
    query_posts(‘cat=’ . get_category_id() . ‘&showposts=1000’);
    $i = 1; // loop counter
    if ( have_posts() ) : while ( have_posts() ) : the_post();
    the_title();

    foreach($posts_columns as $column_name=>$column_display_name) {
    $categories = get_the_category();
    if ( !empty( $categories ) ) {
    $out = array();
    foreach ( $categories as $c )
    if ($c->name != single_cat_title(”, false)) { // used to exclude the current category from the list
    $out[] = “slug’> ” . wp_specialchars(sanitize_term_field(‘name’, $c->name, $c->term_id, ‘category’, ‘display’)) . ““;
    }
    echo join( ‘, ‘, $out );
    } else {
    _e(‘Uncategorized’);
    }
    }
    $i++;
    endwhile; else: endif;`

    Keep in mind, this excludes the current category page that you are on from this list. Also, I used a function in this code named get_category_id() which simply grabs the current category ID from the current page you’re on.

    Where exactly do you implement this?

Viewing 2 replies - 1 through 2 (of 2 total)