• Hey guys,

    I am trying to get a feel for shortcodes, but my test is not working properly. I want to to change [test] with <p>TEST TEXT</p>, but when I put [test] in the page editor, no text shows up.

    Here is what is in my functions.php:

    function test() {
      return '<p>TEST TEXT</p>';
    }
    
    add_shortcode('test', 'test');

    and then I have [test] as the only thing on the page. I am running on localhost, if that matters. Does anyone know what I am doing wrong?

    Thank you!

Viewing 15 replies - 1 through 15 (of 28 total)
  • function test( $atts, $content = null ) {
    return ‘<p>TEST TEXT</p>’;
    }

    add_shortcode(‘test’, ‘test’);

    Thread Starter dstars5

    (@dstars5)

    It still comes out blank.

    Change theme and try.

    Thread Starter dstars5

    (@dstars5)

    Why change the theme? Everything else works, its just the shortcodes?

    Why change the theme? Everything else works, its just the shortcodes?

    Your theme could have same function ‘test’, could have some function which won’t let you have your own shortcodes, could have function to disable shortcodes, coud have removing filter etc, and etc.

    Thread Starter dstars5

    (@dstars5)

    It’s a custom theme. There is nothing to do with shortcodes up to this point.

    It’s a custom theme. There is nothing to do with shortcodes up to this point.

    Add this in your functions.php:
    add_filter('the_content', 'do_shortcode', 11);

    Thread Starter dstars5

    (@dstars5)

    Still nothing

    Thread Starter dstars5

    (@dstars5)

    Does anyone know what I am doing wrong?

    Test it on a default theme.

    Thread Starter dstars5

    (@dstars5)

    It works on the default theme.

    So then there’s something in your theme as suggested above

    Your theme could have same function ‘test’, could have some function which won’t let you have your own shortcodes, could have function to disable shortcodes, coud have removing filter etc, and etc.

    Thread Starter dstars5

    (@dstars5)

    This is my entire functions.php. What is causing the problem, then? This is the first theme I have ever made myself, so I really have no idea what is going wrong.

    <!--sidebar -->
    
    <?php
    
    /*if ( function_exists('register_sidebar') )
    
    // Sidebar Widget
    
    register_sidebar(array('name'=>'right-Sidebar',
    
    'before_widget' => '<li>',
    
    'after_widget' => '</li>',
    
    'before_title' => '<h3>',
    
    'after_title' => '</h3>',
    
    ));*/
    
    function test( $atts, $content = null ) {
    return '<p>TEST TEXT</p>';
    }
    
    add_shortcode('test', 'test');
    ?>
    Thread Starter dstars5

    (@dstars5)

    Hello?

    I replaced the entire functions.php of the twentythirteen theme, and it works properly. I did the same with my custom theme, and it does not work:

    <?php function test( $atts, $content = null ) {
    return '<p>TEST TEXT</p>';
    }
    
    add_shortcode('test', 'test'); ?>
    Thread Starter dstars5

    (@dstars5)

    So does anyone want to help out? Or…?

Viewing 15 replies - 1 through 15 (of 28 total)
  • The topic ‘Shortcode test leads to blank page’ is closed to new replies.