Jump to content

How to add an $exclude???


scofield888

Recommended Posts

Can anyone please help me?

 

I need to add a function/string (not quite sure of the right term) to exclude categories. This is a code that I'm using for my Wordpress website.

 

I'm new to php and really don't know how to make this work.  :confused:

 

Thanks in advance!

         


 

<div style="height: auto;">

                <?php

                $home_url = get_option('home');

               

                //$querystr = "SELECT wp_t.* FROM `wp_terms` AS wp_t LEFT JOIN `wp_term_taxonomy` wp_tt ON (wp_t.term_id = wp_tt.term_id) WHERE wp_tt.taxonomy='category' ORDER BY wp_t.name";

                $querystr = "SELECT wp_t.* from wp_terms as wp_t left join wp_term_taxonomy wp_tt ON (wp_t.term_id = wp_tt.term_id) where wp_tt.taxonomy='category' && wp_t.term_id NOT IN (1,12)";

               

                $categories = $wpdb->get_results($querystr, OBJECT);

               

                //echo '<pre>';

                //print_r($categories);

                //echo '</pre>';

               

                $left_cats = array();

                $right_cats = array();

               

                foreach($categories as $key => $result)

                {

                    $cat_slug = $result->slug; // url

                    $cat_name = $result->name; // name

               

                    if($key % 2)

                    {

                        $right_cats[] = array('slug' => $cat_slug, 'name' => $cat_name);

                    }

                    else

                    {

                        $left_cats[] = array('slug' => $cat_slug, 'name' => $cat_name);

                    }

                }

               

                //if($_SERVER['REMOTE_ADDR'] == '85.122.30.18')

                //{

                //echo "<pre>"; print_r($left_cats); echo "</pre>";

                //echo "<pre>"; print_r($right_cats); echo "</pre>";

                //}

                ?>

            </div>

           

            <div style="float: left; width: 126px;">

                <ul>

                    <?php

                    foreach($left_cats as $c)

                    {

                        //echo '<li><a href="'.$home_url.'/tag/'.$row->slug.'/">'.$row->name.'</a></li>'."\n";

                    ?>

                    <li style="height: auto; border: 1px solid #CFCFCF; padding: 3px 0px 3px 5px; margin: 4px 0px 0px 0px; background-color: #ffffff;"><a href="<?php echo $home_url.'/tag/'.$c['slug'].'/'; ?>"><?php echo $c['name']; ?></a></li>

                    <?php

                    }

                    ?>

                </ul>

            </div>

   

            <div style="float: right; width: 126px;">

                <ul>

                    <?php

                    foreach($right_cats as $c)

                    {

                    ?>

                    <li style="height: auto; border: 1px solid #CFCFCF; padding: 3px 0px 3px 5px; margin: 4px 0px 0px 0px; background-color: #ffffff;"><a href="<?php echo $home_url.'/tag/'.$c['slug'].'/'; ?>"><?php echo $c['name']; ?></a></li>

                    <?php

                    }

                    ?>

                </ul>

            </div>

Link to comment
https://forums.phpfreaks.com/topic/173407-how-to-add-an-exclude/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.