WordPress.org

Ready to get started?Download WordPress

Forums

Shortcode test leads to blank page (29 posts)

  1. dstars5
    Member
    Posted 7 months ago #

    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!

  2. LapanWebsite
    Member
    Posted 7 months ago #

    function test( $atts, $content = null ) {
    return '<p>TEST TEXT</p>';
    }

    add_shortcode('test', 'test');

  3. dstars5
    Member
    Posted 7 months ago #

    It still comes out blank.

  4. LapanWebsite
    Member
    Posted 7 months ago #

    Change theme and try.

  5. dstars5
    Member
    Posted 7 months ago #

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

  6. LapanWebsite
    Member
    Posted 7 months ago #

    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.

  7. dstars5
    Member
    Posted 7 months ago #

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

  8. LapanWebsite
    Member
    Posted 7 months ago #

    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);

  9. dstars5
    Member
    Posted 7 months ago #

    Still nothing

  10. dstars5
    Member
    Posted 7 months ago #

    Does anyone know what I am doing wrong?

  11. WPyogi
    Volunteer Moderator
    Posted 7 months ago #

    Test it on a default theme.

  12. dstars5
    Member
    Posted 7 months ago #

    It works on the default theme.

  13. WPyogi
    Volunteer Moderator
    Posted 7 months ago #

    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.

  14. dstars5
    Member
    Posted 7 months ago #

    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');
    ?>
  15. dstars5
    Member
    Posted 7 months ago #

    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'); ?>
  16. dstars5
    Member
    Posted 7 months ago #

    So does anyone want to help out? Or...?

  17. WPShowCase
    Inactive
    Posted 7 months ago #

    Your custom theme's functions.php is not being included.

    Please make sure it has activated properly and see this guide for creating a theme:
    http://codex.wordpress.org/Theme_Development

    If you follow the instructions for theme development, your theme will work.

  18. dstars5
    Member
    Posted 7 months ago #

    That guide says that the functions.php should be automatically loaded if it is present. What do I need to do to "activate" it?

  19. dstars5
    Member
    Posted 7 months ago #

    Bump. omg. Is everyone just that busy or am I just being ignored? If someone could just have a somewhat constant convo with me, this would be fixed by now.

  20. WPyogi
    Volunteer Moderator
    Posted 7 months ago #

    If someone could just have a somewhat constant convo with me, this would be fixed by now.

    Yeah, well, everyone helping out here is a volunteer, doing it on their own free time, so if you need better help, you should hire someone -

    http://jobs.wordpress.net/

    Probably going to be hard for anyone here to debug a custom theme. Did you read the article above? Have you tried any of these:

    http://codex.wordpress.org/Debugging_in_WordPress

  21. Andrew
    Forum Moderator
    Posted 7 months ago #

    Is everyone just that busy or am I just being ignored?

    Look at this list of threads to get a scale of how busy we are: http://wordpress.org/support/view/no-replies - and take into account that we are helping out in our free time as WPyogi has identified to you.

  22. dstars5
    Member
    Posted 7 months ago #

    I really don't have a problem with waiting, and I understand that everyone here is a volunteer, but people just keep falling off this thread. I finally get someone who chimes in, then they're gone, and I'm left waiting.

    Probably going to be hard for anyone here to debug a custom theme.

    What else do you need? Lapan said there was probably another function blocking it or something, so I posted my functions.php. Could you at least look at that and see if it is in fact a problem with my function.php?

  23. WPyogi
    Volunteer Moderator
    Posted 7 months ago #

    I just put that in a twentytwelve child theme functions file and it worked fine.

    Are you "using" the shortcode [test] someplace?

  24. dstars5
    Member
    Posted 7 months ago #

    Like on the page?

  25. WPyogi
    Volunteer Moderator
    Posted 7 months ago #

    Yes, or in a post.

  26. dstars5
    Member
    Posted 7 months ago #

    Ya I am using it.

  27. dstars5
    Member
    Posted 7 months ago #

    Huh, ok so it turns out it is not just shortcodes. I figured I would start another part of the site that doesn't need shortcodes, and the page just flat out does not show ANY text, shortcode or not.

  28. dstars5
    Member
    Posted 7 months ago #

    Scratch that. I had messed with my index.php, and that messed it up. Normal text DOES work. Shortcodes still DO NOT.

  29. WPyogi
    Volunteer Moderator
    Posted 7 months ago #

    I don't know what else to suggest - except to use the resources already posted above to figure out what's wrong with your theme - someplace other than the functions file.

Reply

You must log in to post.

About this Topic