Title: variable in parameter
Last modified: August 21, 2016

---

# variable in parameter

 *  [sannevanschie](https://wordpress.org/support/users/sannevanschie/)
 * (@sannevanschie)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/variable-in-parameter/)
 * Hi, i need to put the current category id in a parameter, does anyone know how
   to do this?
 * my code is like this:
    `<?php if (is_category()) { //check if current page is
   a category $args = array( ‘numberposts’ => 9, ‘category’ => ‘31,3,11,4,32,29,30,27,28,26,**-
   $cur_cat_id**‘, ‘posts_per_page’ => 9,’paged’ => $paged); }
 * Hope someone knows

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [graphical_force](https://wordpress.org/support/users/graphical_force/)
 * (@graphical_force)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/variable-in-parameter/#post-4339855)
 * So are you executing this code when someone clicks on a category and not a single
   post?
 *  Thread Starter [sannevanschie](https://wordpress.org/support/users/sannevanschie/)
 * (@sannevanschie)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/variable-in-parameter/#post-4339859)
 * yes, i acctually have two columns (loops) with posts, the left one displays of
   instance posts with category id’s 1, 2, 3, the right displays 4, 5 and 6
 * but when someone clicks on a category, they are displayed in the left column (
   loop) so i then want to prevent them from displaying in the right also.
 *  [graphical_force](https://wordpress.org/support/users/graphical_force/)
 * (@graphical_force)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/variable-in-parameter/#post-4339871)
 * I’m confused. You say ‘when they click on a category, they are displayed in the
   left column’ – what are you talking about? Posts from that category? Do you have
   a link that you can share that shows what you are doing?
 *  Thread Starter [sannevanschie](https://wordpress.org/support/users/sannevanschie/)
 * (@sannevanschie)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/variable-in-parameter/#post-4339875)
 * I can’t because it’s a password protected site at the moment.
 * I mean if someone wants to see al the posts for instance from category 6 ,these
   posts are normaly displayed in the right column but now the category displays
   them aswell in the left column and i don’t want that.
 * like this:
 * left – right
    1,2,3 – 4,5,6
 * someone clicks 6 and it’s like this:
    6 – 4,5,6
 * but i want:
    6 – 4,5 (and not 6)
 * I hope this is understandable, sorry i can’t send a link…
 *  [graphical_force](https://wordpress.org/support/users/graphical_force/)
 * (@graphical_force)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/variable-in-parameter/#post-4339913)
 * What about using is_category [http://codex.wordpress.org/Function_Reference/is_category](https://wordpress.org/support/topic/variable-in-parameter/?output_format=md)
 * and they do something like:
 *     ```
       if (is_category( 'catName or id' )){
        $cur_cat_id = id of that Category;
       }
       ```
   
 * and so forth so $cur_cat_id gets the id of each category id by using conditional
   statements.
 *  Thread Starter [sannevanschie](https://wordpress.org/support/users/sannevanschie/)
 * (@sannevanschie)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/variable-in-parameter/#post-4339984)
 * Yes, I solved it like this:
 * before the loop I check the current category
 *     ```
       <?php $category = get_the_category(); ?>
       ```
   
 * Then in the loop I check if it’s a category page, if so, if the post is the same
   category as the current one i continue
 *     ```
       <?php if (is_category()) {
       if (in_category( $category[0]->cat_name )) { continue; }} ?>
       ```
   
 * thanks

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘variable in parameter’ is closed to new replies.

## Tags

 * [parameter](https://wordpress.org/support/topic-tag/parameter/)
 * [variable](https://wordpress.org/support/topic-tag/variable/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 2 participants
 * Last reply from: [sannevanschie](https://wordpress.org/support/users/sannevanschie/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/variable-in-parameter/#post-4339984)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
