Dynamically generate link path to category posts
-
Hello All,
I have a question about generating a link path to a page of grouped posts. Currently there is a landing page that has 6 parent categories listed with a “see all link”. The link is set up to reference the category number:
<a href="<?php bloginfo('url');?>/?cat=<?php echo $category->term_id ?>" class="link long-link"><span><?php echo $category->name;?></span></a>
However I would like to have a semantic url. I have accomplished this elsewhere on the site by utilizing this code in the link:
<a href="<?php bloginfo('url');?>/<?php echo $category->slug;?>" class="link long-link"><span><?php echo $category->name;?></span></a>
However this won’t work since I also need to include the post parent. For example there are 6 categories that reside within the parent Success Stories. I cannot just hard code in the parent since this is used across multiple sections.
Any help would be greatly appreciated – please let me know if I can clarify any of the above.
Thanks!
Nathan
- The topic ‘Dynamically generate link path to category posts’ is closed to new replies.