• Resolved noski2009

    (@noski2009)


    Hi,

    How can I change the function below so I can reorder the menu to display the categories by id and how can I get a category menu item to link to directly to a page.

    function wp_revamp_categories() {
    $category = wp_list_categories(‘depth=4&title_li=&exclude=1&hide_empty=0&echo=0’);
    $category = preg_replace(‘/title=\”(.*?)\”/’,”,$category);
    echo $category;
    }

Viewing 11 replies - 1 through 11 (of 11 total)
  • MichaelH

    (@michaelh)

    See the wp_list_categories article, to see the order= and orderby= arguments.

    how can I get a category menu item to link to directly to a page.

    You’d have to hardcode that link or use the template tag, wp_list_pages().

    Thread Starter noski2009

    (@noski2009)

    Sorry I really don’t get php could you give an example of how the code works, the categories article isn’t that clear?

    Thanks

    Thread Starter noski2009

    (@noski2009)

    And by hardcode I’m assuming you mean setting up a UL list on the header page where the menu is?

    MichaelH

    (@michaelh)

    Wow thought that article was pretty clear

    wp_list_categories('orderby=ID&depth=4&title_li=&exclude=1&hide_empty=0&echo=0');
    Thread Starter noski2009

    (@noski2009)

    Showing me php code is like showing me hyroglifics. I enetered that code and now the entire categories has disappeared??? d’oh!

    function wp_revamp_categories() {
    wp_list_categories(‘orderby=ID&depth=4&title_li=&exclude=1&hide_empty=0&echo=0’);
    echo $category;
    }

    MichaelH

    (@michaelh)

    Sorry thought I should just show you the important part ??

    $category = wp_list_categories('orderby=ID&depth=4&title_li=&exclude=1&hide_empty=0&echo=0');
    Thread Starter noski2009

    (@noski2009)

    Oh dear way’da go me :]

    Ok so that bit works, how do I do get the menu items to go direct to page instead of a list page?

    Thanks again.

    MichaelH

    (@michaelh)

    Maybe someone else will want to jump in about that…

    Thread Starter noski2009

    (@noski2009)

    No worries, thanks for you help thus far.

    Thread Starter noski2009

    (@noski2009)

    I figured out how to do the last bit, a lot easier than I thought it was going to be.

    MichaelH

    (@michaelh)

    It’s considered appropriate to present the solution for others to see. Thanks

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘function wp_revamp_categories’ is closed to new replies.