WordPress The Loop Shortcode

I went searching the other night for a WordPress loop shortcode. I was surprised to find that there were none out there, so I made one. Use this shortcode below to create a loop on a page , post , or sidebar (with some tweaks). Insert in your functions.php or you can create a plugin for it. I have a plugin where I put all my shortcodes and that works quite well.

  • Daniel

    Hi John,

    Great tip. Just one thing.
    Will the above shortcode display only the title? But if I want to display the article, how should I do?

    Best,
    Daniel

    • http://johndturner.com John Turner

      Hi Daniel , you can use any of the WordPress template tags, the_content() , will display your post content.

      • Daniel

        Hi… Thanks for your reply. But I am not a developer, could you give me an example ?

        Best,
        Daniel

  • christina

    Unfortunately, this loop doesnt work for me. :(
    WP says there’s an error and doesnt save the functions.php

    I noticed the last but even if I closed it, it still didnt work.

    Any suggestions?

    • http://johndturner.com John Turner

      hum, I’m not sure, yes php tags are implied

  • http://twitter.com/bainternetsites ohad raz

    i believe that:

    should be :

    • http://johndturner.com John Turner

      yep, you’re correct. code updated! thx!