Title: conditional functions?
Last modified: August 20, 2016

---

# conditional functions?

 *  [gerard](https://wordpress.org/support/users/charismaarts/)
 * (@charismaarts)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/conditional-functions/)
 * Hello: I am using twenty eleven child theme on latest version of wordpress. I
   am pretty experienced in doing custom coding but all of my experience comes from
   using the “thesis” theme which works differently from most other themes. Anyway;
   I am trying to have a function only run in certain pages. I wrote the function
   and put it in my “functions.php” file and it worked but made change to the whole
   site. But when I added a “is_page” statement to try and restrict to one page 
   only the code stopped working. Is this not doable in twentyeleven? Or is there
   some other way to conditionally run functions on some pages and not others?
 * Please let me know,
 * Gerard

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

 *  [shirazdrum](https://wordpress.org/support/users/shirazdrum/)
 * (@shirazdrum)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/conditional-functions/#post-2776520)
 * Themes don’t make any difference in the way the php is executed. People need 
   to understand that the template is only a visual middle-man for your browser.
   Thesis and twenty Eleven in this regard are exactly the same.
 *     ```
       <?php if (is_page('your_page') || is_page('your_page')) { ?>
       // do something
       <?php } ?>
       ```
   
 *  Thread Starter [gerard](https://wordpress.org/support/users/charismaarts/)
 * (@charismaarts)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/conditional-functions/#post-2776523)
 * Thanks for answering. Here is my code:
 *     ```
       <?php
   
       function test_code() {
   
       if (is_page(10428)) {
   
       echo "***TESTING A FUNCTION****";
       }
       }
   
       add_action('after_setup_theme','test_code');
   
       ?>
       ```
   
 * when I remove the “is_page” statement and also its closing “}” this function 
   works fine; but putting this condition on it; it doesnt work at all; do you see
   anything wrong with my code?
 * Thanks,
 * Gerard
 *  [shirazdrum](https://wordpress.org/support/users/shirazdrum/)
 * (@shirazdrum)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/conditional-functions/#post-2776534)
 *     ```
       <?php
       function test_code()
       {
          //whatever you want it to do
       }
       ?>
       ```
   
 *     ```
       <?php if (is_page('your_page') || is_page('your_page')) {
       // output function
       echo test_code();
       }else{
       //do this
       }
       ?>
       ```
   

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

The topic ‘conditional functions?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [shirazdrum](https://wordpress.org/support/users/shirazdrum/)
 * Last activity: [13 years, 10 months ago](https://wordpress.org/support/topic/conditional-functions/#post-2776534)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
