Category Dreaming...

…on such a Winter’s Day.

California Dreamin’ • “Room Service” • José Feliciano ★★★

Okay, that’s just a silly lead-in to what I’m going to post about. For some time, I’ve been trying to get Category Pages to handle a bit nicer in Blogsome. I needed to be able to get a Category ID from a Category name, and I hadn’t figured out how to. I’d basically given up. Then I found my new best friend, {get_cat_ID cat_name='Cat_Name'}. He allows me to do this. And much easier than I thought it would be, too.

    {if $smarty.server.REQUEST_URI|truncate:10:'':1 == '/category/'}
        {capture name=cat}
            {single_cat_title}
        {/capture}     
        {capture name=catID}
            {get_cat_ID cat_name=$smarty.capture.cat}
        {/capture}
    {/if}

Now, how do we use this to get child categories?

    {list_cats optionall='0' list='false' child_of='$smarty.capture.catID'}

This appears to not work, as it continues to get all of the categories. I think there is an issue with child_of, at least on Blogsome.

    {get_category_children id=$smarty.capture.catID}

Only generates the IDs of the child categories. Useful, but not excellent for my uses. However, there exists also a function called {wp_list_cats}, which allows for arguments in the for &arg=value.

    {wp_list_cats args=&child_of=`$smarty.capture.catID`”} 

Notably, you must use double quotes when trying to embed a variable inside an argument. Final code (not counting CSS, that’s up to you - or look in my StyleSheet):

{if $smarty.server.REQUEST_URI|truncate:10:'':1 == '/category/'} 
    {*Category Index Page*}
    <div class=“catNav”>
        {capture name=cat}{single_cat_title}{/capture}
        {capture name=catID}
            {get_cat_ID cat_name=$smarty.capture.cat}
        {/capture}
        Currently browsing 
        {get_category_parents category="`$smarty.capture.catID`" link="1" separator="&raquo;"}, which has sub-categories 
        <ul class=“inlineCatList”>
            {wp_list_cats args=&&list=0&children=0&child_of=`$smarty.capture.catID`”}
        </ul>
    </div>
{/if}

And, thanks to minimalnet, since because of the post in the forums: How can i show the Dashboard Blog Stats in my blog?, I began scouring the source code again.

Summer The First TimeBobby GoldsboroRoom Service