Outputting parents category

Tagged: , , ,

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #27414

    Hi there,

    Inside the post-functions.php (framework>functions) I’m trying to write code to output parent category name with url link.
    For example, post “I like sweet things” belongs to category “gummy” that has parent category “lollipop”. I want to be able to output “lollipop” with url going to lollipop (not direct category gummy but its parent).

    My code is below and it seems very close, however this code outputs “gummy” for category name but url is of “lollipop”. The URL is correct but category name should output parents name (lollipop) too. By the way, when post category doesn’t have parent, this outputs category name and url both correctly.


    It would be great if you could take a look.
    Thank you as always.



    The code is slightly modified and now I can see “lollipop” (parent cat name and url pointing that parent cat). But for other post which doesn’t have parent category lost category output.

    For example when the post “I like sweet things” belongs to “gummy” that has no parent, there will be no cat name output (neither gummy nor its url pointing to gummy). As a result inside <span class=”category”> becomes empty.

    I think this code above only works for the post that belongs to category which has parent.

    *With the very first code http://pasted.co/b5f13504 works fine only for the post belongs to category which doesn’t have parent.

    *With the second code http://pasted.co/a2169175 works fine only for the post belongs to the category which has parent.

    I need to somehow combine those two…


    Glad you were able to resolve this even though we were not able to attend to this on time. Thanks for letting us know.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Invent Theme Support’ is closed to new topics and replies.