Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2012
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Exclude category names

    Hello, I'm trying to alter my site code to only retrieve certain categories. Specifically, I want to exclude a few category names from the basic retrieval code. Here is the code I currently have:

    PHP Code:
    <!-- Begin #colRight -->
            <div id="colRight">
            <?php 
            
    if(get_option('boldy_blog')!='' && is_category(get_option('boldy_blog')) || post_is_in_descendant_categoryget_option('boldy_blog'))){
            
    $current get_the_category();
            if(
    sizeof($current)>0){ 
            
    $current_id$current[0] ->cat_ID
            
    $categs_list get_category_parents($current_id);
            
    $pieces explode("/"$categs_list);
            
    $category_name strtolower($pieces[0]);
            
    $categs get_cat_id($category_name);
            
    ?>
            <div class="rightBox">
                <h2><?php echo get_cat_name(get_option('boldy_blog'));?> Categories </h2>
                <ul >
                    <?php    
                    $categories 
    get_categories('hide_empty=1&child_of='.$categs);
                    foreach (
    $categories as $cat) {
                        echo (
    '<li><a href="');
                        echo (
    get_category_link($cat->cat_ID).'">'.$cat->cat_name.'</a></li>');
                        }
    ?>
                </ul>
            </div>
            <?php }}?>
            
            <?php /* Widgetized sidebar */
        
    if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?><?php endif; ?>
            
            </div>
    <!-- End #colRight -->

    Some of the categories I want to remove are called:
    • Around the Web
    • Guides
    • Reflections
    • Interviews


    Thanks for the help!

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,500
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Is it WordPress?

  • #3
    New Coder
    Join Date
    Jan 2012
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Yes, a Wordpress blog on my own site.

  • #4
    New Coder
    Join Date
    Jan 2012
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Here is a link to my site if that helps. I'm trying to change the sidebar feature called "Blog Topics"

  • #5
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,500
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    I'm just sort of taking a stab at this one. Make a safe copy of your current script
    before overwriting it. I'm thinking that instead of "get_categories", you will use
    "list_categories" and specify the one's you want.

    You currently are using the permalink (without an id number), but your categories
    still have id numbers associated with them. View your categories in your admin and
    note the id numbers for each one. You'll see in my example, I just put random
    category numbers there ... switch those with the ones you want to appear in
    your sidebar list.


    PHP Code:
    <div class="rightBox"> 
                <h2><?php echo get_cat_name(get_option('boldy_blog'));?> Categories </h2> 
                <ul > 
                    <?wp_list_categories('include=12,5,8,10,3,4&title_li=');?>
                </ul> 
            </div>
    Here are the types of things you'll be using online for information .. WP CODEX

    http://codex.wordpress.org/Template_...ude_Categories
    http://codex.wordpress.org/Function_...get_categories

    Use the CODEX website for all of your specific customization needs:
    http://codex.wordpress.org/Main_Page



    .

  • Users who have thanked mlseim for this post:

    swedy13 (01-14-2012)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •