I’m trying to build up a menu of category links for specific categories I’d like to highlight and apply styling/classes to.
I’ve tried this sort of thing.
<li><a href="<?php get_site_url(); ?>category/Gadgets"> Gadgets</a></li>
And
<li><a href="category/Gadgets"> Gadgets</a></li>
It’s showing up as sitename/category/category/category/gadgets on the front end.
I can’t use <?php wp_list_categories('orderby=name&title_li='); ?>
because it’s going to spit out all of them and limit the styling I can do on the html.
I just want to link to categories directly, by name, preferably without hard coding in the site name.
There is a function called get_category_link() which might be helpful for you. This will be able to generate an appropriate link without having to hard-code it, except for the category name or ID.
Examples from the WordPress Codex:
http://codex.wordpress.org/Function_Reference/get_category_link
Specific to your demand, try this:
use
wp_list_categories('include=3,5,9,16');
, replace “3,5,9,16” with your category ids ( comma separatedanother method
see wordpress codex here
One more method is to create category menu in admin and print it in your theme ( if theme supports menus )
get_site_url()
returns a string with the URL, it does not print it. So you may tryor better: