Title: Override theme&#039;s shortcodes.php
Last modified: August 20, 2016

---

# Override theme's shortcodes.php

 *  Resolved [graphic_dev](https://wordpress.org/support/users/graphic_dev/)
 * (@graphic_dev)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/override-themes-shortcodesphp/)
 * I have created a child theme to override a theme that i bought. The original 
   theme has a file called functions/shortcodes.php which has the following function:
 *     ```
       function ag_divider( $atts, $content = null ) {
           extract(shortcode_atts(array(
           ), $atts));
   
       	$out = '<div class="divider"><h5><span>'.do_shortcode($content).'</span></h5></div>';
   
           return $out;
       }
       add_shortcode('divider', 'ag_divider');
       ```
   
 * How do I override this function in my child theme? All I want to do is change
   the <h5> to an <h2>, but I rather not do this in the original file.

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/override-themes-shortcodesphp/#post-2795560)
 * I’d suggest that you remove the original shortcode in your child theme’s function.
   php file and then set up a new version in the same file.
    [http://codex.wordpress.org/Function_Reference/remove_shortcode](http://codex.wordpress.org/Function_Reference/remove_shortcode)
 *  Thread Starter [graphic_dev](https://wordpress.org/support/users/graphic_dev/)
 * (@graphic_dev)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/override-themes-shortcodesphp/#post-2795694)
 * I can’t remove the shortcode from my child theme’s functions.php file… I tried
   adding the following in the original theme’s shortcodes.php:
    `remove_shortcode('
   divider' );` which works fine, so the code seems right. But it doesn’t work when
   I move that same code to functions.php in my child theme…
 * What am I doing wrong?
 * _[[please do not bump]](http://codex.wordpress.org/Forum_Welcome#No_Bumping)_
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/override-themes-shortcodesphp/#post-2795736)
 * try and use a ‘after_theme_setup’ section in functions.php of the child theme;
 * example:
 *     ```
       add_action( 'after_setup_theme', 'my_ag_child_theme_setup' );
   
       function my_ag_child_theme_setup() {
          remove_shortcode( 'divider' );
          add_shortcode( 'divider', 'my_ag_divider' );
       }
   
       function my_ag_divider( $atts, $content = null ) {
           extract(shortcode_atts(array(
           ), $atts));
       	$out = '<div class="divider"><h2><span>'.do_shortcode($content).'</span></h2></div>';
           return $out;
       }
       ```
   
 *  Thread Starter [graphic_dev](https://wordpress.org/support/users/graphic_dev/)
 * (@graphic_dev)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/override-themes-shortcodesphp/#post-2795749)
 * Thanks alchymyth, that worked perfectly!
 *  [Cypher-kun](https://wordpress.org/support/users/cypher-kun/)
 * (@cypher-kun)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/override-themes-shortcodesphp/#post-2795876)
 * It helped my too.
    Thanks guys!

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

The topic ‘Override theme's shortcodes.php’ is closed to new replies.

 * 5 replies
 * 4 participants
 * Last reply from: [Cypher-kun](https://wordpress.org/support/users/cypher-kun/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/override-themes-shortcodesphp/#post-2795876)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
