Are there any dependencies on which shortcode depends?

[news_weber][/news_weber] → Didn't work, but when used with do_shortcode method it worked.

I installed Ultimate shortcode plugin to check whether that works or not. all the shortcodes of that plugin worked, strangely as soon as that plugin was installed my custom shortcodes also worked and as soon as uninstalled my custom shortcodes stopped working. what is the connection?

are there any dependencies that are not included in my theme and they get included as soon as some third-party plugin is installed?

Update →

  1. The shortcode works if used in the post(edit mode) editor, and
  2. It also works with do_shortcode method, but
  3. It doesn't work when we use the default text widget and place our shortcode there. However, it works here also If we install the plugin as I told you above.

enter image description here

what is the issue?

Update 2: Code →

function burner() {
        //some code
        return ob_get_clean();
add_shortcode('news_burner', 'burner');

Update #3

Shortcodes are plugin territory so I transferred them to a plugin, but the same problem they do not work, but when I install a 3rd party plugin as stated above they do work.

  • 1
    Where's the news_weber shortcode coming from? There's no code in your question to debug – Tom J Nowell Oct 6 '17 at 16:49
  • Sir, i have updated the question. – The WP Intermediate Oct 7 '17 at 1:43
  • I have updated the code of one shortcode. – The WP Intermediate Oct 7 '17 at 1:51
  • news_weber shortcode is in shortcode.php and that file is included in functions.php Additionally, the shortcode works in the post editors. – The WP Intermediate Oct 7 '17 at 2:03
  • Have you tried just using [news_weber]? Without the closing shortcode? – Tom J Nowell Oct 7 '17 at 2:03

Problem 1

It doesn't work because you're using new_weber but you're registering news_burner, and they aren't the same

So instead use:


You only need a closing shortcode if it's containing content which that plugin does not.

Problem 2

Shortcodes don't work in text widgets out of the box, you can add that functionality via a plugin though, see this question/answer:

Shortcode in Text Widget not working

This is why it works with do_shortcode but not in widgets. It'll also work in post content

| improve this answer | |
  • [new_weber ] for Aweber; [news_burner] for Feedburner. I have total 4: aweber, mailchimp, Feedburner, feedblitz – The WP Intermediate Oct 7 '17 at 2:08
  • 1
    Great, see the problem 2 section – Tom J Nowell Oct 7 '17 at 2:09
  • sir, I didnt get this completely → "you can add that functionality via a plugin though" means my own custom text widget? – The WP Intermediate Oct 7 '17 at 2:11
  • 1
    sir mystery solved → add_filter( 'widget_text', 'do_shortcode', 11 ); I added this and it worked. – The WP Intermediate Oct 7 '17 at 2:20

Based on your question and my understanding of your question, you have to make sure that your shortcode is called from your functions files.

First, you need to write <?php echo do_shortcode("[news_weber]"); ?> in order to make it work by PHP. Based on your question, I think you do not need the closing bracket since shortcodes can be self-closed.

Documentation : https://developer.wordpress.org/reference/functions/do_shortcode/

But even if you typed this correctly, you still need to give the access to this shortcode in your function file.

You could create a custom file named shortcodes.php and call it from your functions.php file.

if ( ! function_exists( 'my_theme_setup' ) ) :

   function my_theme_setup() {

   // Custom shortcodes
   require_once( "inc/shortcodes.php" );


add_action( "after_setup_theme", "my_theme_setup" );

And in your shortcode.php file you can call your function.

function news_weber_func( $atts ) {
    // Your custom code
add_shortcode( 'news_weber', 'news_weber_func' );

Official documentation : https://codex.wordpress.org/Function_Reference/add_shortcode

I hope it will help you.

| improve this answer | |
  • sir, I have updated the question. Please check. – The WP Intermediate Oct 7 '17 at 1:43
  • If I use shortcode w/o closing bracket then even after that plugin is installed it doesn't work. – The WP Intermediate Oct 7 '17 at 1:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.