Outputting parents category

This topic is: resolved

Tagged: , , ,

This topic contains 3 replies, has 2 voices, and was last updated by Raghavendra Raghavendra 2 years, 3 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #27414
    Palmtree
    palmtree
    Participant
    Post count: 126

    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
    palmtree
    Participant
    Post count: 126

    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
    palmtree
    Participant
    Post count: 126
    #27455
    Raghavendra
    Raghavendra
    Moderator
    Post count: 4682

    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)

You must be logged in to reply to this topic.