• Resolved mrspabs

    (@mrspabs)


    I am trying to build a category breadcrumb. i have this code

    <?php
    $category = get_the_category(); echo $category[1]->cat_name; ?>/<?php
    $category = get_the_category(); echo $category[0]->cat_name; ?>/<?php echo $post->post_name; ?>

    Any my categories are like this

    Long Island
    – Uniondale
    – Happauge

    The weird thing is, sometimes the categories print like this

    Long Island / Happauge / Post Name
    Uniondale / Long Island / Post Name

    I tried unassigning and reassigning the category, but that doesn’t seem to work.

    So long story short, how can i change the order of the array of categories assigned to a post?

Viewing 2 replies - 1 through 2 (of 2 total)
  • order by id?

    Thread Starter mrspabs

    (@mrspabs)

    Here is an answer to my own question 🙂

    This code will output the categories in the correct order.
    <?php echo get_category_parents($cat, FALSE, ‘/’); ?>

    if you do this, it will do it with links
    <?php echo get_category_parents($cat, TRUE, ‘/’); ?>

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

The topic ‘Category order’ is closed to new replies.