• Im using the GamePlan theme by Envato Market.

    By the time I finish my site, Im going to have roughly over 10,000 pages. Each of these pages is meant to give a person a star rating (using the multi-star plugin).

    Im wondering if there is a way to make it default so that every page when created automatically comes with the multi-star rating plugin (rather than me having to go into every page and adding the short code)? Please let me know, thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    Yes! Hook the ‘default_content’ filter 🙂

    Another possibility is to use ‘the_content’ filter to insert the shortcode into all posts of a certain category or some other criteria when they are output instead of saving the shortcode with the content in the DB. I forget if you can append the shortcode here or if you need to explicitly expand it with do_shortcode(). One way or the other will work. This way you don’t even need to delete the default shortcode in posts where it’s not needed, the code “knows” when it’s needed automatically.

    I am working on a site ethnicforever.com please tell how to make url seo friendly in WordPress and also how SEO Yoast can be used for seo purpose.Any suggestion will be very helpful and useful for me please visit the website and recommend me what i should do.Thanks in advance.

    Thread Starter Ratethetrainers

    (@ratethetrainers)

    Thanks bcworkz! Now how exactly do I find the ‘default_content’ page? Haha, sorry, Im a little new to this all. Its like a whole new language.

    Moderator bcworkz

    (@bcworkz)

    Just like there is a Shortcode API, there is also a Plugin API that explains actions and filters. ‘default_content’ and ‘the_content’ are not pages at all, they are “filters”. You “hook” onto these filters to effect change to the default behavior of WP. This is done by creating a function that does something you want done, then calling add_filter() so that WP knows to call your function at the appropriate time.

    To add default content, your callback function would simply return your desired shortcode. The best place to place little customizations like this is either a custom site specific plugin or a child theme. Both of these are easy to create, the specifics can be found in the Codex.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to make short codes default on every page’ is closed to new replies.