I added a shortcode for preg_replace to my SHORTcURL Plugin

Now, with a shortcode for the single most powerful PHP function there is (preg_replace), I dare to imagine that there is nothing that this simple plugin cannot do.

If you know what this amazing function, preg_replace, is capable of then put it to the test.

Here is an example of the syntax for the new new shortcode that calls preg_replace:

[preg_replace replace=”/to be searched/” with=”I replaced”]<li>The content to be searched</li>[/preg_replace]

and this is what you get:

  • The content I replaced

  • My new Plugin for making cURL calls

    I created this plugin that uses a shortcode to call wp_remote_get with parameters you pass to parsed and display a bit of HTML from a page on another site. You can include this shortcode in your page or post.

    Here is an example of the shortcode that will display the Download Stats page for this Plugin on WordPress.org:
    [remote_get url="https://wordpress.org/plugins/shortcurl/stats/" start='&lt;div class="block-content"' stop='!-- block-content--' length="-1"].
    and this is what you get:
    EZ SHORTCURL Shortcodes to Fetch and Parse External Content — WordPress Plugins

    EZ SHORTCURL Shortcodes to Fetch and Parse External Content


    Use the shortcode “remote_get” with the parameter “url” to insert the content from that url into your page or post. You can also use parameters like start and stop (or end) to parse out a specific part of the content that you wish to display.

    Now you can also wrap any content in the “preg_replace” shortcode to manipulate it into the desired format. Tricky stuff, but very powerful, if you know what you’re doing.

    Updated August-3rd


    1. Download and unzip the plugin into your WordPress plugins directory (usually /wp-content/plugins/).
    2. Activate the plugin through the ‘Plugins’ menu in your WordPress Admin.


    What do I do after I activate the Plugin?

    Use the shorcode remote_get with a url parameter on a page or post to bring in external content.

    What does a example of the shortcode look like?

    [remote_get url=”https://wordpress.org/plugins/shortcurl/stats/” start='<div class=”block-content”‘ stop=’!– block-content–‘ length=”-1″ replace=”=’/extend” with=”=’https://wordpress.org/extend” replace2=”%2Fextend%2F” with2=”http%3A%2F%2Fwordpress.org%2Fextend%2F”]


    Read all 3 reviews

    Contributors & Developers

    “EZ SHORTCURL Shortcodes to Fetch and Parse External Content” is open source software. The following people have contributed to this plugin.




    • Added a Shortcode Widget with pop-out position options.


    • Replaced the SESSION code with the use of GLOBALS for broader compatibilty.


    • Fixed the “with” parameter in to remote_get function to accempt empty string.
    • Decoded HTML Entities in the URL parameter to improve the handling of GET variables in the URL String.
    • Improved the error messages by adding what URL triggered the error.


    • Added a shortcode for str_replace simple string manipulation.
    • Added support for arrays in preg_replace shortcode.
    • Added an alternate shortcode for running preg_replace on another shortcode vs. on the results of another shortcode.

    • Added a shortcode for preg_replace to further manipulate content.

    • Fixed error handling on line 71 to report the whole curl error on the admin pages.

    • Fixed call to plugin_row_meta.

    • Added 24 hour caching to speed up page loads.
    • Added admin_notices if fatching or parsing produces any errors.

    • First versions uploaded to WordPress.