Title: Checkboxes and functions.php
Last modified: August 20, 2016

---

# Checkboxes and functions.php

 *  Resolved [St0nee](https://wordpress.org/support/users/st0nee/)
 * (@st0nee)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/checkboxes-and-functionsphp/)
 * Hi all,
    I want to make a filter using checkboxes that would allow users to filter
   articles by ticking one or multiple checkboxes, each checkbox representing a 
   specific tag.
 * For Example:
 *     ```
       <form action="<?php get_the_selected(); ?>" method="post">
       <input type="checkbox" name="selections[]" value="tag1" />Select1<br />
       <input type="checkbox" name="selections[]" value="tag2" />Select2<br />
       <input type="checkbox" name="selections[]" value="tag3" />Select2<br />
       <input type="submit" name="formSubmit" value="Submit" />
       </form>
       ```
   
 * This is just an example, I am using like 20 or more checkboxes..
    Now when you
   check one or two or three chechboxes and click submit button, I want to make 
   the function that would generate a tag link like this: `site_url/?tag=tag1+tag2
   +tag3` or tag1+tag2 or tag1.. depending on the selection…
 * I was searching the web and found something that I thought would work
    [here.](http://www.html-form-guide.com/php-form/php-form-checkbox.html)
 * But the problem is that this tutorial isn’t done using wordpress.. And when I
   try to add function in functions.php
 *     ```
       function get_the_selected() {
        $allselected = $_POST['selections'];
         if(empty($allselected))
         {
           echo("You didn't select anything.");
         }
         else
         {
           $N = count($allselected);
           echo("You selected $N: ");
           for($i=0; $i < $N; $i++)
           {
             echo($allselected[$i] . " ");
           }
         }
       }
       ```
   
 * It’s not working.. to be precise, even when I check some boxes, I still get that
   I didn’t check any.. I know that this function probably would not achieve my 
   desired result, but for now I would like to just make it so it could correctly
   detect my checked boxes…
    This is the first time I am doing something like this…
   🙂
 * Also, when I created checkbox-form.php file and put all the code.. it detected
   everything fine.. So I think that this function needs only some minor adjustments,
   but the lack of my skill prevents me from writing the correct function
 * So, could anyone help me make the correct function ? I hope you understoon what
   I’m after. I would really appreciate any thoughts, suggestions, ideas 🙂
 * Thank you in advance,
    St0nee

Viewing 1 replies (of 1 total)

 *  Thread Starter [St0nee](https://wordpress.org/support/users/st0nee/)
 * (@st0nee)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/checkboxes-and-functionsphp/#post-2646755)
 * got it. 🙂

Viewing 1 replies (of 1 total)

The topic ‘Checkboxes and functions.php’ is closed to new replies.

## Tags

 * [box](https://wordpress.org/support/topic-tag/box/)
 * [boxes](https://wordpress.org/support/topic-tag/boxes/)
 * [check](https://wordpress.org/support/topic-tag/check/)
 * [checkboxes](https://wordpress.org/support/topic-tag/checkboxes/)
 * [function](https://wordpress.org/support/topic-tag/function/)
 * [link](https://wordpress.org/support/topic-tag/link/)
 * [tags](https://wordpress.org/support/topic-tag/tags/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [St0nee](https://wordpress.org/support/users/st0nee/)
 * Last activity: [14 years, 2 months ago](https://wordpress.org/support/topic/checkboxes-and-functionsphp/#post-2646755)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
