Title: Override HTML output from a function
Last modified: August 22, 2016

---

# Override HTML output from a function

 *  Resolved [robertosalemi](https://wordpress.org/support/users/robertosalemi/)
 * (@robertosalemi)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/override-html-output-from-a-function/)
 * Good Morning!
 * I would like to figure out how I can edit, via the functions.php of my ChilTheme,
   the HTML code generated by a function of the thema.
 * I have this code:
 *     ```
       function crumina_social_icons()
       {
           global $one_touch_option;
   
           if (!$one_touch_option['expand_social_icons']){
               $class="closed";
           } else {
               $class="opened";
           }
       	if ($one_touch_option['soc_ico_panel']) :
   
           echo '
           <div class="row"><div class="large-12 columns">
           <div id="panel">
   
               <a id="open-social-button" href="#">
                   <i class="linecon-globe"></i>
                   <span class="desc">' . __('Pagine SOCIAL', 'crum') . '</span>
                   <span>' . __('GDP', 'crum') . '</span>
               </a>
               <div id="soc-icons-wrap" class="' . $class . '">';
   
                   crum_social_networks();
   
               echo '</div>
           </div>
           </div></div>';
   
       	endif;
       }
   
       add_action('reactor_header_after', 'crumina_social_icons', 2);
       ```
   
 * I was trying to create a function like:
    `add_filter('reactor_header_after', '
   crumina_social_icons_custom');` to replace the text “Pages SOCIAL” or other …
 * How should I proceed?
 * Thanks.

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

 *  [geraintp](https://wordpress.org/support/users/geraintp/)
 * (@geraintp)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/override-html-output-from-a-function/#post-5499582)
 * you cant filter an action..
 * you need to remove the action and replace it with your own so something like 
   this…
 *     ```
       <?php 
   
       // Deregister original function and register replacement
       function switch_crumina_social_icons()
       {
       	remove_action('reactor_header_after', 'crumina_social_icons', 2);
       	add_action('reactor_header_after', 'my_crumina_social_icons', 2);
       }
       add_action('after_setup_theme', 'switch_crumina_social_icons');
   
       /* NB. this is tricky but this action need to hook after the function
        * is original registered but before it is executed otherwise it will miss it.
        * 'after_setup_theme' should be about right.
        */
   
       // Replacement function
       function my_crumina_social_icons()
       {
       	# copy original code... here
       	....
       	# change as required.
       }
   
       ?>
       ```
   
 *  Thread Starter [robertosalemi](https://wordpress.org/support/users/robertosalemi/)
 * (@robertosalemi)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/override-html-output-from-a-function/#post-5499628)
 * Hi geraintp,
    thanks for your support, but this solution doesn’t work.
 * If you see [this screenshot](https://dl.dropboxusercontent.com/u/50056863/wp_gdp_remove_default_function_add_custom.jpg),
   this hook generates a duplicate where the first row is created by the new functions
   and the second from the default.
 * Maybe I must change ‘reactor_header_after’ with another $hook?
 * Thanks.
 *  [geraintp](https://wordpress.org/support/users/geraintp/)
 * (@geraintp)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/override-html-output-from-a-function/#post-5499641)
 * Hi ok,
 * basically were hooking in too early, so the initial action hasn’t been added 
   before we’ve tried to replace it.
 * [http://codex.wordpress.org/Plugin_API/Action_Reference](http://codex.wordpress.org/Plugin_API/Action_Reference)
 * try changing
 *     ```
       add_action('after_setup_theme', 'switch_crumina_social_icons');
       ```
   
 * to
 *     ```
       add_action('init', 'switch_crumina_social_icons');
   
       or
   
       add_action('wp_loaded', 'switch_crumina_social_icons');
       ```
   
 *  Thread Starter [robertosalemi](https://wordpress.org/support/users/robertosalemi/)
 * (@robertosalemi)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/override-html-output-from-a-function/#post-5499653)
 * Hi geraintp,
    I resolved with your solution:
 *     ```
       function switch_crumina_social_icons()
       {
       	remove_action('reactor_header_after', 'crumina_social_icons', 2);
       	add_action('reactor_header_after', 'my_crumina_social_icons', 2);
       }
       add_action('init', 'switch_crumina_social_icons');
       ```
   
 * Thanks for your support!

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

The topic ‘Override HTML output from a function’ is closed to new replies.

## Tags

 * [override function](https://wordpress.org/support/topic-tag/override-function/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [robertosalemi](https://wordpress.org/support/users/robertosalemi/)
 * Last activity: [11 years, 5 months ago](https://wordpress.org/support/topic/override-html-output-from-a-function/#post-5499653)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
