How to write shortcodes

  • Unknown's avatar

    (Note: This is a follow-up to a post thread in Blogging 201-Customization, in which posting is now closed. I’m tagging @kathrynwp here as part of the follow-up, but if there’s someone else on the support team here who also has some helpful tips for shortcode newbies, please feel free to say something! Thanks!)

    I wish to create a shortcode that will post a specific grouping of posts together on one static page. But since I’m still new at writing shortcode and I’m not getting the results I was hoping for, I’m wondering if I should still stick with keeping the designated posts in a category. Anyway, I tried posting a shortcode that I had copied and pasted from one of the examples in a help article and then changing the tag variable. Since then, I deleted the “strong” posts and then saved the page. Still, nothing has happened. Maybe the experimental shortcode I posted is not the right one for what I want to accomplish, or maybe I’m not entering the shortcode in the right place (is it in the visual or the HTML editor where this should go?). I thought the article said it was the visual editor.

    Even though I’m not sure about using a static page for this purpose, I still want to know how to do it in case I decide to switch some or even most of the older posts to a static page. Thanks for your help so far, as I’ve learned a lot in the Blogging 201 Customization course and have signed up for a new class in December.

    The blog I need help with is: (visible only to logged in users)

  • Unknown's avatar

    I wish to create a shortcode that will post a specific grouping of posts together on one static page. But since I’m still new at writing shortcode and I’m not getting the results I was hoping for, I’m wondering if I should still stick with keeping the designated posts in a category.

    It may depend on how you’re looking to group them, but generally categorizing them is the way to go. If you can give me a few details on what the grouping is based on, I can give you more specific advice.

    Anyway, I tried posting a shortcode that I had copied and pasted from one of the examples in a help article and then changing the tag variable

    What shortcode are you using?

  • Unknown's avatar

    Thanks for responding to this post. As I mentioned, I’m new to shortcodes and so I’m not even really sure what this shortcode does. Anyway, here’s the shortcode. I then added the tag that’s been attached to the posts (sidewalk chalk talk) and then changed the original number from “20” to “45”. I wanted to get all the posts from the category Sidewalk Chalk Talk onto one page, just as older posts and a blog can be put onto a static page.

    [display-posts tag="sidewalk chalk talk" posts_per_page="45]

    Also, I have another question about setting up a static page, but for now I’ll stick to the shortcode question here. Thanks again!

  • Unknown's avatar

    As a first step, I’d recommend having a look at this guide to learn more about the difference between tags and categories. They’re pretty similar, but generally, tags are more specific than categories.

    Categories vs. Tags

    I’d tend to avoid using identical tags and categories. My impression is that “Sidewalk Chalk Talk” should be only a category.

    I wanted to get all the posts from the category Sidewalk Chalk Talk onto one page, just as older posts and a blog can be put onto a static page.

    It’s not really necessary to use a shortcode for this, as you can already see only Sidewalk Chalk Talk posts at:

    https://onesunnyplace.wordpress.com/category/msn-space-days/sidewalk-chalk-talk/

    However, if you wanted to make a customized page, and put that category’s posts on there, you could use this shortcode:

    [display-posts category="sidewalk-chalk-talk"]

    You can simply paste this shortcode, like any other shortcodes, in your post or page editor.

    Learn more about the display-posts shortcode, and shortcodes generally, here:
    https://en.support.wordpress.com/shortcodes/

    Display Posts Shortcode

  • Unknown's avatar

    @chrisrudski –

    Thanks so much for helping me understand a little more about shortcodes than I did. It’s good to know that I have some options re. categories and static pages, and if I want to create a static page about something else, I can now do so. Besides, I think now that sticking with Sidewalk Chalk Talk as a category is best.

    Since I’m between blogs at the moment, I’m figuring out which things work best for each blog. The more I learn, the more exciting it gets as I see this blog and the other one take shape; sometimes the simplest things and changes are the best. Thanks again!

  • Unknown's avatar

    @sunnygal66 — You’re very welcome! I wish you happy blogging, and if you’re just getting started, you might like these: http://learn.wordpress.com and https://dailypost.wordpress.com/blogging-university/

  • The topic ‘How to write shortcodes’ is closed to new replies.