开发者

Wordpress category href issue

Hi I was just wondering if there was any way using wordpress to change the Href of the li items outputted from this;

<?php
                    if (is_category()) {
                         $this_category = get_category($cat);
                    if (get_category_children($this_category->cat_ID) != "") {
                         echo "<ul&g开发者_JAVA技巧t;";
                         echo str_replace('','', wp_list_categories('orderby=id&show_count=0&title_li=
                         &use_desc_for_title=1&child_of='.$this_category->cat_ID));
                         echo "</ul>";
                         }
                    }
                ?>

So that the Href is simply an anchor to the id of the category li that has been pressed ie, the anchor within li item cat-item-11 would have a href of "#cat-item11"

Hope that makes sense!

Cheers


There is not a way to tell wp_list_categories to add that to the link. You would likely be on the hook for writing your own function to pull out categories and display them as a nested list.

If you are open to a javascript solution, you could easily loop through the li elements when the page loads and add the hash to the url then. If you were using the hash for some sort of ajax effects, then there would definitely be no reason not to go that route.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜