WordPress.org

Ready to get started?Download WordPress

Forums

do_shortcode returns null content (5 posts)

  1. Rebecca Schaefer
    Member
    Posted 2 years ago #

    On one of the sites I manage, I have a custom shortcode for displaying content that (long story short) had to be manually placed/rearranged before. The shortcode works on other sites using it, but on this one it fails when I play it at the very top of the page content.

    The way the sites are set up, a page holds the content for the front page (but it's separate from the page set as the front page). The shortcode is placed in the content page. I retrieve that page using get_page(), then run $page->post_content through wpautop() and then run do_shortcode() on the autop'd content. (Yes, I know this process is convoluted, just roll with it.)

    So, I get content back during wpautop(). Everything is fine and dandy. I get output from the shortcode function when I var_dump() instead of return. But, if I let it fully process do_shortcode() the content switches from lovely, formatted content to NULL. Unless I move the shortcode to the bottom of the content. Then it works just fine.

    Any ideas on why it would clobber all the content? There's nothing wrong with the code - it's working on many other sites - so it has to be some unaccounted difference in the content, but I have no clue where to start looking.

  2. Peter Baylies
    Member
    Posted 2 years ago #

    So you've tested this on the latest WordPress 3.3 / trunk? I ask because I do see a bug that could be related. Is do_shortcode() processing a lot of content?

  3. Rebecca Schaefer
    Member
    Posted 2 years ago #

    Sorry, I selected the wrong version. I'm actually on 3.2.1.

  4. Peter Baylies
    Member
    Posted 2 years ago #

    See if you can reproduce the same bug in trunk on a test site; if you can't, then maybe you're being affected by a bug that got fixed in 3.3.

  5. Rebecca Schaefer
    Member
    Posted 2 years ago #

    I'll give that a shot later today. Thanks for the suggestion!

Topic Closed

This topic has been closed to new replies.

About this Topic