Listing current and sibling categories and creating a link to the first post
-
I’m creating a website that has two menus – a main header menu and a side menu. The side menu changes according to the category of the current post.
The current category setup is:
Products
-Product 1
–Description
–Advantages
-Product 2
–Description
–Advantages
-Product 3
–Description
–AdvantagesIf I’m in a post that is in Description, I would like to show the side menu as the current and sibling category – Description and Advantages of that product.
Next, once I show the the Description and Advantages, I’d like for each of them to link to the first post in that category (rather than to the category itself).
Until now, I’ve used a combination of different codes from different areas. This is what I’d like to create:
<br /> <?php List current and sibling category of current post (subcategories of parent) ?><br /> <href="1st post of subcategory"><?php Subcategory name ?></a><br />
This is where I am (which isn’t very far!):
</p> <ul> <?php<br /> $category = get_the_category();<br /> echo $category[0]->cat_name;</p> <p>wp_list_categories('orderby=id&show_count=0&title_li=&use_desc_for_title=0&child_of='.$category->post_parent.'&echo=0'); ?> </ul> <p>
I’m great at understanding how the code works, but not very good at devising it!!
Any help would be greatly appreciated!
- The topic ‘Listing current and sibling categories and creating a link to the first post’ is closed to new replies.