Outputting parents category

Tagged: , , ,

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

    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.

    http://pasted.co/b5f13504

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

    #27428
    palmtree
    Participant

    http://pasted.co/a2169175

    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.

    [Summary]
    *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…

    #27450
    palmtree
    Participant
    #27455
    Raghavendra
    Moderator

    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.