WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Boilerplate] Is there an equivalent of do_shortcode() for boilerplates? (6 posts)

  1. DataGnostics
    Member
    Posted 2 years ago #

    When I try to display content from a page that includes a boilerplate on a different page, the boilerplate isn't processed, '[boilerplate plate = "foo"]' appears right there on the page. Is there an equivalent of do_shortcode for wp-boilerplate?

    If not, how would I write my own such function?

  2. DCoda
    Member
    Posted 2 years ago #

  3. DataGnostics
    Member
    Posted 2 years ago #

    No, that doesn't do it.

    I've got a function, called by a shortcode, that takes the content of all pages with the tag "soon" and puts them on the News page. Part of the function runs like this:

    $soon_text .= $soonlink . get_the_title().'</a></h3>';
    $thiscontent = get_the_content();
    $coded_content = do_shortcode( $thiscontent );
    $soon_text .= $coded_content;
    If there is a shortcode inside that page's content, "do_shortcode" processes it so it displays properly on the News page.

    However, if I have a boilerplate on that page, it is *not* processed, and [boilerplate plate = "foo"] is right there for all to see.

    I need a way to nest the boilerplate within a *shortcode*, not just within another boilerplate.

  4. DCoda
    Member
    Posted 2 years ago #

    Boilerplate is not a true shortcode it is a filter. This is done because shortcodes are low priority, lower than filters. This would mean the inserted text would not be filtered, which in most cases would not be good.
    If the do_action does not work in your situation you could try

    $coded_content = apply_filters( 'the_content', $thiscontent );

    It might achieve what you need.

  5. DataGnostics
    Member
    Posted 2 years ago #

    YES! That worked! Thank you very much.

  6. Paul
    Member
    Posted 2 years ago #

    Hey there, having an issue with this, Shortcode works fine in the content, when placed in a template (I've used the do_action as described on your site) with no joy - any help would be greatly appreciated.

    Other than this snag an all round awesome plugin.

Topic Closed

This topic has been closed to new replies.

About this Topic