• Hi guys!!

    I would like to change the code of how categories are showed. I use two parents categories: Location and topic.

    I would like to change this php code:
    <span class=”cat-links”><?php printf(__(‘Posted in %s’, ‘sandbox’), get_the_category_list(‘, ‘) ) ?></span>

    bu other that shows only Location parent category, just putting “Location: …” and it should show the subcategory of location I chose.

    I hope someine understand it.

    https://www.igmosi.com/blog

    thanks!!!

Viewing 5 replies - 1 through 5 (of 5 total)
  • I think I basically understand what you’re trying to do, though it looks like you’ve already figured this out? For example, on the post I looked at it had this:

    Location: Finland ? Helsinki

    Let me know if you were trying to do something different.

    Thread Starter Pedro

    (@igmosi)

    Hi thanks!!

    no, that is written in body of the post. I would like to do it where categories are showed (right of the picture), like:
    Location: (should be showed the cateogires I choose, that case Finland)
    Topic: (should be showed the cateogires I choose, that case Street art)

    I would like to modify the code to show those 2 different group of categories. My categories are divided in 2 (topic and location) parents field. I have gone through that and I guess I have to change the function get_the_category_list(‘, ‘) , but i havent figured it out.

    got it?

    thanks!!!

    Not a good idea to change ‘core code’ … probably should use Template_Tags/get_the_category then display those as you see fit.

    Thread Starter Pedro

    (@igmosi)

    Ok, I got it,

    but how I select the parent “LOCATION” in this sentences;

    <?php the_category( $separator, $parents, $post_id ); ?>

    should be:

    <?php the_category( ‘ , ‘, ‘Location’); ?>

    it didnt work.

    You need to use the id of the Location category, not the name. So if the ID of the Location category is 2, you’d have something like:

    <?php $location = get_the_category(' ,', '2', $post->ID);
    echo $location; ?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Show only a parent category’ is closed to new replies.